本文整理汇总了Python中matplotlib.backends.backend_agg.FigureCanvasAgg.buffer_rgba方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasAgg.buffer_rgba方法的具体用法?Python FigureCanvasAgg.buffer_rgba怎么用?Python FigureCanvasAgg.buffer_rgba使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_agg.FigureCanvasAgg
的用法示例。
在下文中一共展示了FigureCanvasAgg.buffer_rgba方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cut_axes_and_save_svgs
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import buffer_rgba [as 别名]
def _cut_axes_and_save_svgs(figure, axes, x_lim, delta_total, data_name,
tile_gradient_end, tile_gradient_st, preserve_ratio=False):
for i, lh in enumerate(last_hours):
file = os.path.join(path_dest, 'tile_{}_{}_last_{}h.svg'.format('enerpi_data', data_name, lh))
axes.set_xlim((x_lim[0] + delta_total * (1 - lh / total_hours), x_lim[1]))
figure.set_figwidth(_tile_figsize(lh / total_hours)[0])
write_fig_to_svg(figure, name_img=file, preserve_ratio=preserve_ratio)
# if (i + 1 == len(last_hours)):
if EXPORT_PNG_TILES and (i + 1 == len(last_hours)):
path_png = file[:-3] + 'png'
base_path, name_png = os.path.split(path_png)
figure.set_dpi(216)
canvas = FigureCanvas(figure)
canvas.draw()
# Fusion data + bg:
data_img = Image.frombytes('RGBA', (900, 600), canvas.buffer_rgba())
png_img = _get_png_tile_background(os.path.join(base_path, 'fondo_' + name_png),
(data_img.width, data_img.height),
tile_gradient_end, tile_gradient_st)
png_img.paste(data_img, (0, 0), data_img)
png_img.save(path_png)
示例2: vtkRenderer
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import buffer_rgba [as 别名]
cubeTexture.InterpolateOn()
cubeTexture.SetInput(imflip.GetOutput())
cubeActor.SetTexture(cubeTexture)
ren = vtkRenderer()
ren.AddActor(cubeActor)
win = plugInManager['VtkWindow'].winManager.newWindow()
win.vtkWidget.GetRenderWindow().AddRenderer(ren)
# Now create our plot
fig = Figure()
canvas = FigureCanvasAgg(fig)
ax = fig.add_subplot(111)
ax.grid(True)
ax.set_xlabel('Hello from VTK!', size=16)
ax.bar(xrange(10), p.rand(10))
# Powers of 2 image to be clean
w,h = 1024, 1024
dpi = canvas.figure.get_dpi()
fig.set_figsize_inches(w / dpi, h / dpi)
canvas.draw() # force a draw
# This is where we tell the image importer about the mpl image
extent = (0, w - 1, 0, h - 1, 0, 0)
importer.SetWholeExtent(extent)
importer.SetDataExtent(extent)
importer.SetImportVoidPointer(canvas.buffer_rgba(0,0), 1)
importer.Update()