[ Web Proxy ]
URL:
Viewing: https://matplotlib.org/users/../examples/pylab_examples/agg_buffer_to_array.html [Back]  [Original]

pylab_examples example code: agg_buffer_to_array.py — Matplotlib 2.0.2 documentation
You are reading an old version of the documentation (v2.0.2). For the latest version see https://matplotlib.org/stable/
forkme_right_orange_ff7600.png [forkme_right_orange_ff7600.png]
matplotlib [matplotlib]
depsy_badge.svg [depsy_badge.svg]
Travis-CI: matplotlib.svg [matplotlib.svg]

This Page

pylab_examples example code: agg_buffer_to_array.py

(Source code)

import matplotlib.pyplot as plt
import numpy as np

# make an agg figure
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
ax.set_title('a simple figure')
fig.canvas.draw()

# grab the pixel buffer and dump it into a numpy array
X = np.array(fig.canvas.renderer._renderer)

# now display the array X as an Axes in a new figure
fig2 = plt.figure()
ax2 = fig2.add_subplot(111, frameon=False)
ax2.imshow(X)
plt.show()

Keywords: python, matplotlib, pylab, example, codex (see Search examples)


Web Proxy Viewer  |  New URL  |  Original Page