Huanian Zhang
Huanian Zhang

Reputation: 860

Python Matplotlib plt.show() does not return the figure

I remote login a server using ssh -X ***@remote.arizona.edu (This remote server is a Linux system) and tried to make some plots using Python, I had the following errors:

_tkinter.TclError: no display name and no $DISPLAY environment variable

Then I fixed this error by the adding the commands before I import any matplotlib:

import matplotlib
matplotlib.use('Agg')
matplotlib.matplotlib_fname()

Now it runs well. But the problem is that there is no figure displayed even if I had the command plt.show(). My old computer used Ubuntu 16.04 before, there is no such problem. Now I switched to MacBook Air, then I had this issue. It must be some Mac setting issues. Any thoughts to fix this issue?

Upvotes: 0

Views: 564

Answers (1)

halloleo
halloleo

Reputation: 10454

You need to install XQuartz on your Macbook. Then make sure the DISPLAY variable in your remote shell is set to your local X server. Now the remote matplotlib should show the figure on your Macbook.

Upvotes: 1

Related Questions