FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/misc/agg_buffer_to_array.py at unpyplot · a52/matplotlib · GitHub
a52
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
misc
/
agg_buffer_to_array.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (20 loc) · 551 Bytes
Breadcrumbs
matplotlib
/
examples
/
misc
/
agg_buffer_to_array.py
Copy path
File metadata and controls
24 lines (20 loc) · 551 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
===================
Agg Buffer To Array
===================
Convert a rendered figure to its image (NumPy array) representation.
"""
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
.
buffer_rgba
())
# 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
()
Back
|
FazBrowse Home
|
New Git URL