2

How can I share an object between processes?

Say I make

import matplotlib.pyplot as plt
fig = plt.figure() 
ax=fig.add_subplot(111) 
ax.scatter(x,y)

I want this ax to be shared so that all processes makes plot referring to the same ax (same memory address). So that when I save the figure all plots created by all processes are superimposed in one .png window.

  • You should just be able to make the Matplotlib object a global. Then use "locks" when accessing the object, [more here.](https://docs.python.org/3/library/threading.html#lock-objects) Other than that use normal multithreading. See what you get after this. – Preston Hager Jan 01 '17 at 10:51
  • @PrestonHager How can I make Matplotlib object global? –  Jan 01 '17 at 14:25
  • 2
    Here is an example on how to use multiprocessing with matplotlib: http://stackoverflow.com/a/41056050/4124317 – ImportanceOfBeingErnest Jan 01 '17 at 18:34

0 Answers0