Created
November 14, 2013 14:46
-
-
Save ignisan/7468042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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