- Notifications
You must be signed in to change notification settings - Fork 908
/
Copy pathcolorbar.py
28 lines (21 loc) · 825 Bytes
/
colorbar.py
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
# -----------------------------------------------------------------------------
# Matplotlib cheat sheet
# Released under the BSD License
# -----------------------------------------------------------------------------
importpathlib
importnumpyasnp
importmatplotlibasmpl
importmatplotlib.pyplotasplt
ROOT_DIR=pathlib.Path(__file__).parent.parent
fig=plt.figure(figsize=(6, .65))
# ax = plt.subplot(111, frameon=False, aspect=.1)
b=0.025
ax=fig.add_axes([b, 10*b, 1-2*b, 1-10*b], frameon=False, aspect=0.05)
cmap=plt.get_cmap("Oranges")
norm=mpl.colors.Normalize(vmin=0, vmax=1)
sm=plt.cm.ScalarMappable(cmap=cmap, norm=norm)
sm.set_array([])
plt.colorbar(sm, cax=ax, ticks=np.linspace(0, 1, 11),
orientation="horizontal")
fig.savefig(ROOT_DIR/"figures/colorbar.pdf")
# plt.show()