Workflows and plotting with matplotlib crashing ? #457
-
Seems like workflows having matplotlib is either crashing or the ones that finish off seems to plot it multiple times when looking at results |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Just starting a quick discussion, seems like one needs to add in extra work when designing tasks that involves plotting with matplotlib. Since matplotlib shares a global instance of figures with Trick is to do this @ct.electron
def plot():
import matplotlib
matplotlib.use("Agg")
fig,ax=plt.subplots()
ax.scatter([1],[1])
matplotlib.pyplot.close()
return fig,ax This ( |
Beta Was this translation helpful? Give feedback.
Just starting a quick discussion, seems like one needs to add in extra work when designing tasks that involves plotting with matplotlib. Since matplotlib shares a global instance of figures with
plt.plot
, one has to turn off the backend to make sure it does not show up. This becomes crucial when running in executers as since even in case of local electrons, each task seems to open up its own matplotlib instance and not shut it down.Trick is to do this
This (
matplotlib.pyplot.close()
) also prevents the plots from direc…