pyplot while using X11 forwarding

2019-04-15 06:53发布

问题:

I'm trying to setup my remote working environment so that I can use matplotlib.pyplot under ipython. My local machine and remote machine are both MAC OSX Mavericks. I've tried xeyes and it works properly so I think my X11 forwarding works fine. However, when I try functions in matplotlib.pyplot it didn't show any error message but I didn't see any figure either.

I know it's about which backend to use and I've tried using ipython --pylab=tk but didn't work. Tried to install pygtk but can't manage to install a dependency py2cairo (seems to be an open issue). Any other thoughts? Thanks.

回答1:

How did you "try functions in matplotlib.pyplot"?

The following works for me

import matplotlib
matplotlib.use('tkagg')
import matplotlib.pyplot as plt
plt.plot([1, 2, 3])
plt.show()