FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/units/units_scatter.py at pre-commit · ianhi/matplotlib · GitHub
ianhi
matplotlib
Repository navigation
Code
Pull requests
5
(5)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
units
/
units_scatter.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (23 loc) · 678 Bytes
Breadcrumbs
matplotlib
/
examples
/
units
/
units_scatter.py
Copy path
File metadata and controls
30 lines (23 loc) · 678 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
25
26
27
28
29
30
"""
=============
Unit handling
=============
The example below shows support for unit conversions over masked
arrays.
.. only:: builder_html
This example requires :download:`basic_units.py <basic_units.py>`
"""
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
from
basic_units
import
secs
,
hertz
,
minutes
# create masked array
data
=
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
)
mask
=
(
1
,
0
,
1
,
0
,
0
,
0
,
1
,
0
)
xsecs
=
secs
*
np
.
ma
.
MaskedArray
(
data
,
mask
,
float
)
fig
, (
ax1
,
ax2
,
ax3
)
=
plt
.
subplots
(
nrows
=
3
,
sharex
=
True
)
ax1
.
scatter
(
xsecs
,
xsecs
)
ax1
.
yaxis
.
set_units
(
secs
)
ax2
.
scatter
(
xsecs
,
xsecs
,
yunits
=
hertz
)
ax3
.
scatter
(
xsecs
,
xsecs
,
yunits
=
minutes
)
fig
.
tight_layout
()
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL