Skip to content

Instantly share code, notes, and snippets.

@ignisan
Created November 14, 2013 14:46
Show Gist options
  • Save ignisan/7468042 to your computer and use it in GitHub Desktop.
Save ignisan/7468042 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
#vim:fileencoding=utf8
import matplotlib
matplotlib.rcParams['backend'] = "Agg"
from StringIO import StringIO
import pylab as pl
import numpy as np
import sixel
def main():
pl.figure(figsize=(6,4))
x = np.linspace(0,2*np.pi)
y = np.sin(x)
pl.plot(x,y)
buf = StringIO() # ファイルっぽいもの
pl.savefig(buf) # bufに保存。ファイルじゃないよ!
buf.seek(0) # ここポイント。無いとダメ。
writer = sixel.SixelWriter()
writer.draw(buf)
if __name__=="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment