欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python matplotlib畫圖實例之繪制擁有彩條的圖表

 更新時間:2017年12月28日 17:06:07   投稿:mengwei  
這篇文章主要介紹了Python matplotlib畫圖實例之繪制擁有彩條的圖表,具有一定借鑒價值,需要的朋友可以參考下

生產(chǎn)定制一個彩條標簽。

首先導入:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from numpy.random import randn

制作擁有垂直(默認)彩條的圖表:

fig, ax = plt.subplots()

data = np.clip(randn(250, 250), -1, 1)

cax = ax.imshow(data, interpolation='nearest', cmap=cm.coolwarm)
ax.set_title('Gaussian noise with vertical colorbar')

# Add colorbar, make sure to specify tick locations to match desired ticklabels
cbar = fig.colorbar(cax, ticks=[-1, 0, 1])
cbar.ax.set_yticklabels(['< -1', '0', '> 1']) # vertically oriented colorbar

效果圖:

制作擁有水平彩條的圖表:

fig, ax = plt.subplots()

data = np.clip(randn(250, 250), -1, 1)

cax = ax.imshow(data, interpolation='nearest', cmap=cm.afmhot)
ax.set_title('Gaussian noise with horizontal colorbar')

cbar = fig.colorbar(cax, ticks=[-1, 0, 1], orientation='horizontal')
cbar.ax.set_xticklabels(['Low', 'Medium', 'High']) # horizontal colorbar

plt.show()

效果圖:

腳本運行耗時:(0分0.075秒)

總結(jié)

以上就是本文關(guān)于Python matplotlib畫圖實例之繪制擁有彩條的圖表的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!

相關(guān)文章

最新評論