📄 to_numeric.py
字号:
#!/usr/bin/env python"""Use backend agg to access the figure canvas as an RGB string and thenconvert it to a Numeric array and pass the string it to PIL forrendering"""from pylab import *from matplotlib.backends.backend_agg import FigureCanvasAggplot([1,2,3])canvas = get_current_fig_manager().canvasagg = canvas.switch_backends(FigureCanvasAgg)agg.draw()s = agg.tostring_rgb() # get the width and the height to resize the matrixl,b,w,h = agg.figure.bbox.get_bounds()w, h = int(w), int(h)X = fromstring(s, UInt8)X.shape = h, w, 3import Imageim = Image.fromstring( "RGB", (w,h), s)im.show()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -