2016-05-17 83 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

相关问题