How to plot a chart in the terminal?

后端 未结 7 1315
面向向阳花
面向向阳花 2020-12-25 09:13

I\'m researching ML/Theano, and recently came across this script: https://gist.github.com/notmatthancock/68d52af2e8cde7fbff1c9225b2790a7f which was cool to play with. And l

7条回答
  •  不思量自难忘°
    2020-12-25 09:39

    You have a couple of options here:

    1. Export to image or PDF. Information found here: http://matplotlib.org/faq/howto_faq.html The key piece of information here is below:

      # do this before importing pylab or pyplot
      import matplotlib
      matplotlib.use('Agg')
      import matplotlib.pyplot as plt
      fig = plt.figure()
      ax = fig.add_subplot(111)
      ax.plot([1,2,3])
      fig.savefig('test.png')
      
    2. If your server supports X11 forwarding (or if you can enable/install X11 forwarding), you can SSH into the server by setting your display. From linux, run:

      DISPLAY=:0.0 ssh -Y 
      

      This will set up your machine to forward any display output from the server to your PC. If you are running Windows, you can use MobaXterm which makes it easy, or configure an X11 client yourself. Mac is similarly easy if I remember correctly.

提交回复
热议问题