简体   繁体   中英

How to change colorbar using Matplotlib?

if I'm plotting a contour like this, how could I change the color bar for "jet" colour? Is it necessary to call a figure first?

plt.contourf(X,Y,Z)
plt.colorbar().set_label(label='values',size=12)
plt.grid(True)

You can supply a parameter to the contourf function:

plt.contourf(X, Y, Z, cmap=plt.cm.jet)

or

plt.contourf(X, Y, Z, cmap='jet')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM