[英]Custom HeatMap Issue on Scale and legend
我嘗試創建自定義熱圖,但在 y 尺度上有問題。
我構建的代碼如下:
cmap = colors.ListedColormap(['red','green']) bounds=[-1,1] norm = colors.BoundaryNorm(bounds, cmap.N) heatmap = plt.pcolor(np.array(result), cmap=cmap, norm=norm) plt.colorbar(heatmap, ticks=[-1,0,1])
result是 3 列 6 行的數組,其中包含 -1 或 1 個值
result
我怎樣才能編輯它以獲得
0 1 2 3
您可以修改刻度范圍和頻率:
plt.xticks(np.arange(0, 4, 1.0))
將從 0 到 4(不包括 4,所以直到 3)進行刻度,它們之間的間隔為 1。
[英]Seaborn heatmap with a custom legend
[英]Bokeh Heatmap Legend
[英]Legend label Heatmap Plotly
[英]heatmap simple customized binary legend
[英]Python - Seaborn: Modifying the heatmap legend
[英]Add a legend to my heatmap plot
[英]Discrete legend in seaborn heatmap plot
[英]Color scale by rows in Seaborn Heatmap
[英]How to add a second scale to a heatmap?
[英]Plotly : Heatmap color legend i subplot
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.