Matplotlib cannot generate figures

Hi, I’m trying to use the matplotlib module in the new ScriptEditor in Rhino 8. When I use the command plt.show() I get the following error:

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

Is there any workaround for this?

P.S. here a minimum working example:

# r: matplotlib

import matplotlib.pyplot as plt 

plt.plot([0,1,2],[10,23,45])
plt.show()

Hi, I tried running your minimum working example (found this thread after unsuccessfully trying to plot from a more complex script), which did run, but Rhino 8 (the released version, not the WIP anymore) crashed with this lovely out of memory warning.

I run Rhino on an M1 Max MBP with 64GB of memory, so it would be a shame if this plot would kill it.
Can someone at McNeel take a look or provide guidance how to get matplotlib working with Rhino?

Thanks!

(My desired use case would be to use it to plot various energy simulation results from Honeybee.)

1 Like

Hi ! @GIOVANNI_PAGNON

My personal workaround is to use plt.savefig() instead.

Then use other components to read the image back with a given path.
I’m doing building physics so I personally use the image viewer in the Ladybug Tools, but I guess there are other alternative components.

The link above mentioned a more hard-core method but I didn’t test. But I guess it could be helpful if you want to explore more choices.

2 Likes

Great idea, I always forget that the image viewer shows anything you throw at it…

I’m curious about what you do!

There is the youtrack page for this bug, it was opened a while ago but if you want to stay updated on the progress I guess here we can get the latest info:
https://mcneel.myjetbrains.com/youtrack/issue/RH-74046

1 Like