2016-05-17 82 views
1

matplotlib command summary for the colorbar method我知道作爲一個參數關鍵字參數orientation := 'horizontal' | 'vertical'放置一個水平情節或垂直正確的它分別我可以在matplotlib圖的左側放置一個垂直的彩條嗎?

然而,在我的情況下,我寧願將顏色欄放在默認的對面(如果可能,沒有太多的擺弄)。

我該如何編碼?我是否缺少一些明顯的特徵?

+0

一個這樣做的方法是由彩條手動創建額外的軸:http://matplotlib.org/實例/ pylab_examples/multi_image.html – numentar

回答

4

我認爲最簡單的方法是確保顏色條在自己的軸上。你可以從這個例子適應:

import matplotlib.pyplot as plt 
import numpy as np 

fig = plt.figure() 
ax = fig.add_subplot(111) 
axp = ax.imshow(np.random.randint(0, 100, (100, 100))) 
# Adding the colorbar 
cbaxes = fig.add_axes([0.1, 0.1, 0.03, 0.8]) # This is the position for the colorbar 
cb = plt.colorbar(axp, cax = cbaxes) 
plt.show() 

導致此:

Matplotlib colorbar on the left side of plot

相關問題