Loading and using MathLab Plots in Grasshopper with Python 3

Hello again sir,
I tried to load matplotlib.pyplot.show() to test if other packages are possible to load in gh, but unfortunately after that I couldn’t load pandas again! Can you please kindly check this screenshot and help me again?

What seems to be the problem? I don’t see any errors in script editor

plt.show() doesn’t work for some reason (it works, but the window that should show the plot disappears very fast). You can use plt.savefig() instead, like this example:

The code runs, but the window that shows the plot appears and disappears in 0.1 second. You can see the icon of it in the taskbar when you run it continuously, but there is nothing to see. It should be in another thread, but when I try to use selenium and especially webdriver.wait(), the grasshopper can’t handle it and freezes.maybe there is problem with external windows.

1 Like

@sadra Yes external windows need a rhino backend for matplotlib that I have a ticket for to get fixed:

RH-74046 CPython matplotlib needs a Rhino/Eto backend probably (affects pandas)

1 Like

not sure it’s the right subforum, but since you’ve already had some discussion, I best ask here

Any suggestions how to modify my code as to allow for continuous update/rewrite of the matplotlib inside gh if input values change. The issues has to do with that I try to resave the images, which is prohibited as the file is open in grasshopper. And making new version of the saved image file works, but will result in 10’s if not hundreds of files if it and playing with the sliders.

i couldn’t get @farouk.serragedine solution to work: How to install libraries like SciPy into Rhino 8 beta script editor? - #5 by farouk.serragedine

r8_python3_matplotlib.gh (18.8 KB)

I’m on my phone now , but what if you generate images with another python component(split the logic maybe) and connect timer to it🤔

If I remember currently it make the script too slow if you connect timer to the main one :thinking:, but give it a try .

  • you can also use grasshoppe native components to display images