How to plot a chart in the terminal?

后端 未结 7 1322
面向向阳花
面向向阳花 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:40

    It is possible to plot raster images in terminals and terminal emulators:

    import matplotlib
    matplotlib.use('module://matplotlib-sixel')
    from pylab import *
    plt.plot(sin(arange(100) / 10))
    show()
    

    This particular example uses matplotlib-sixel, a library that uses Xterm emulating a Sixel compatible terminal and ImageTrick. Similar technology could be implemented in the Linux terminal (through the Framebuffer) or emulators (kitty or iTerm2). The FOSS community has given great solutions in the last years (like libsixel).

    Another option would be using X11 forwarding or using a Sixel-based printer like lsix. But all these options would happens outside the Python shell itself.

    Of course, you are probably better off running a Jupyter Notebook in the server than trying to shoehorn an image in a terminal. It is probably not worth it.

提交回复
热议问题