色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

python matplotlib imshow熱圖坐標替換/映射實例

瀏覽:32日期:2022-08-02 11:32:07

今天遇到了這樣一個問題,使用matplotlib繪制熱圖數組中橫縱坐標自然是圖片的像素排列順序,

但是這樣帶來的問題就是畫出來的x,y軸中坐標點的數據任然是x,y在數組中的下標,

實際中我們可能期望坐標點是其他的一個范圍,如圖:

python matplotlib imshow熱圖坐標替換/映射實例

坐標點標出來的是實際數組中的下標,而我希望縱坐標是頻率,橫坐標是其他的范圍

plt.yticks(np.arange(0, 1024, 100), np.arange(10000, 11024, 100))#第一個參數表示原來的坐標范圍,100是每隔100個點標出一次#第二個參數表示將展示的坐標范圍替換為新的范圍,同樣每隔100個點標出一次plt.xticks(np.arange(0, 2000, 500), np.arange(0, 50000, 500)) #同理將x軸的表示范圍由(0,2000)擴展到(0,50000)每隔500個點標出一次

python matplotlib imshow熱圖坐標替換/映射實例

完成!

補充知識:matplotlib plt.scatter()中cmap用法

我就廢話不多說了,還是直接看代碼吧!

import numpy as npimport matplotlib.pyplot as plt# Have colormaps separated into categories:# http://matplotlib.org/examples/color/colormaps_reference.htmlcmaps = [(’Perceptually Uniform Sequential’, [ ’viridis’, ’plasma’, ’inferno’, ’magma’]), (’Sequential’, [ ’Greys’, ’Purples’, ’Blues’, ’Greens’, ’Oranges’, ’Reds’, ’YlOrBr’, ’YlOrRd’, ’OrRd’, ’PuRd’, ’RdPu’, ’BuPu’, ’GnBu’, ’PuBu’, ’YlGnBu’, ’PuBuGn’, ’BuGn’, ’YlGn’]), (’Sequential (2)’, [ ’binary’, ’gist_yarg’, ’gist_gray’, ’gray’, ’bone’, ’pink’, ’spring’, ’summer’, ’autumn’, ’winter’, ’cool’, ’Wistia’, ’hot’, ’afmhot’, ’gist_heat’, ’copper’]), (’Diverging’, [ ’PiYG’, ’PRGn’, ’BrBG’, ’PuOr’, ’RdGy’, ’RdBu’, ’RdYlBu’, ’RdYlGn’, ’Spectral’, ’coolwarm’, ’bwr’, ’seismic’]), (’Qualitative’, [ ’Pastel1’, ’Pastel2’, ’Paired’, ’Accent’, ’Dark2’, ’Set1’, ’Set2’, ’Set3’, ’tab10’, ’tab20’, ’tab20b’, ’tab20c’]), (’Miscellaneous’, [ ’flag’, ’prism’, ’ocean’, ’gist_earth’, ’terrain’, ’gist_stern’, ’gnuplot’, ’gnuplot2’, ’CMRmap’, ’cubehelix’, ’brg’, ’hsv’, ’gist_rainbow’, ’rainbow’, ’jet’, ’nipy_spectral’, ’gist_ncar’])]nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps)gradient = np.linspace(0, 1, 256)gradient = np.vstack((gradient, gradient))def plot_color_gradients(cmap_category, cmap_list, nrows): fig, axes = plt.subplots(nrows=nrows) fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99) axes[0].set_title(cmap_category + ’ colormaps’, fontsize=14) for ax, name in zip(axes, cmap_list): ax.imshow(gradient, aspect=’auto’, cmap=plt.get_cmap(name)) pos = list(ax.get_position().bounds) x_text = pos[0] - 0.01 y_text = pos[1] + pos[3]/2. fig.text(x_text, y_text, name, va=’center’, ha=’right’, fontsize=10) # Turn off *all* ticks & spines, not just the ones with colormaps. for ax in axes: ax.set_axis_off()for cmap_category, cmap_list in cmaps: plot_color_gradients(cmap_category, cmap_list, nrows)#十分類散點圖繪制randlabel = np.random.randint(0,1,10)randdata = np.reshape(np.random.rand(10*2),(10,2))cm = plt.cm.get_cmap(’RdYlBu’)z = randlabelsc = plt.scatter(randdata[:,0], randdata[:,1], c=z, vmin=0, vmax=10, s=35,edgecolors=’k’, cmap=cm)plt.colorbar(sc)plt.show()

以上這篇python matplotlib imshow熱圖坐標替換/映射實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 亚洲国产高清一区二区三区 | 亚洲欧洲日产v特级毛片 | 亚洲精品久一区 | 一个人看的免费高清视频日本 | 欧美性色黄大片一级毛片视频 | 久久精品国产午夜伦班片 | 日韩高清不卡在线 | 日韩在线不卡一区在线观看 | 国产短裙黑色丝袜在线观看下 | 久久黄色一级视频 | 亚洲精品在线网 | 手机免费黄色网址 | 香蕉视频老司机 | 国产一区二区日韩欧美在线 | 欧美亚洲国产一区 | 视频一区二区三区自拍 | 亚洲精品不卡久久久久久 | 欧美又粗又硬又大久久久 | 亚洲天堂色视频 | 国产精品成人在线 | 87精品福利视频在线观看 | 国产dvd毛片在线视频 | 一本色道久久88亚洲精品综合 | 成人精品网| 欧美性色生活免费观看 | 久久国产精品歌舞团 | 91热久久 | 成人五级毛片免费播放 | 日韩在线视频免费 | 男女扒开双腿猛进入免费网站 | 亚洲欧美在线综合一区二区三区 | 久久精品免看国产成 | 日韩成人精品日本亚洲 | 纯欧美一级毛片免费 | 亚洲国产精品线在线观看 | 欧美freesex10一13黑人 | 亚洲精品一级片 | 经典香港a毛片免费观看 | 日产乱码精品一二三区 | 国产毛片a精品毛 | 亚洲1314|