FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/colorbar_only.py at transforms · tecki/matplotlib · GitHub
tecki
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
colorbar_only.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (22 loc) · 822 Bytes
Breadcrumbs
matplotlib
/
examples
/
colorbar_only.py
Copy path
File metadata and controls
28 lines (22 loc) · 822 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
'''
Make a colorbar as a separate figure.
'''
import
pylab
import
matplotlib
as
mpl
# Make a figure and axes with dimensions as desired.
fig
=
pylab
.
figure
(
figsize
=
(
8
,
1.5
))
ax
=
fig
.
add_axes
([
0.05
,
0.05
,
0.9
,
0.9
])
# Set the colormap and norm to correspond to the data for which
# the colorbar will be used.
cmap
=
mpl
.
cm
.
cool
norm
=
mpl
.
colors
.
Normalize
(
vmin
=
5
,
vmax
=
10
)
# ColorbarBase derives from ScalarMappable and puts a colorbar
# in a specified axes, so it has everything needed for a
# standalone colorbar. There are many more kwargs, but the
# following gives a basic continuous colorbar with ticks
# and labels.
cb
=
mpl
.
colorbar
.
ColorbarBase
(
ax
,
cmap
=
cmap
,
norm
=
norm
,
orientation
=
'horizontal'
)
cb
.
set_label
(
'Some Units'
)
pylab
.
show
()
Back
|
FazBrowse Home
|
New Git URL