Skip to content

Workflows and plotting with matplotlib crashing ? #457

Discussion options

You must be logged in to vote

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

@ct.electron
def plot():
    import matplotlib
    matplotlib.use("Agg")
    fig,ax=plt.subplots()
    ax.scatter([1],[1])
    matplotlib.pyplot.close()
    return fig,ax

This ( matplotlib.pyplot.close() ) also prevents the plots from direc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by santoshkumarradha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant