2

I create a virtual server using compute engine. I can ssh through their ssh button. But when I run my code which has matplotlib it will not show the plot while I am not getting any error! here is my code for matplotlib:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

plt.plot(history.history['loss'], label='train')
plt.plot(history.history['val_loss'], label='test')
plt.legend()
plt.show()

when I run echo $DISPLAY it returns nothing and then I run export DISPLAY=localhost:0 but still pyplot is not working. Is it possible to show it at all on GCE? or I am doing s.th wrong!

Sepid
  • 107
  • 1
  • 10
  • Possible duplicate of [Matplotlib: display plot on a remote machine](https://stackoverflow.com/questions/3453188/matplotlib-display-plot-on-a-remote-machine) – sascha Sep 30 '17 at 22:44
  • The main point is that using the `"Agg"` backend, `plt.show()` has no effect and no plot is shown. This is what the `"Agg"` backend is made for: no GUI output. Whether you may actually get a graphical output using a different backend (`"TkAgg"`, `"GTK"`, `"PyQt4Agg"`, ...) may also depend on the server. – ImportanceOfBeingErnest Sep 30 '17 at 23:26

0 Answers0