以下是示例,testOrigin()工作,第二轴翻转图像。但是,testGridOrigin()总是在所有轴上显示翻转图像或非翻转图像。任何人都可以告诉我为什么会这样吗?有任何解决这个问题的方法吗?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
from matplotlib import colors
def testOrigin():
x = np.arange(100.0); x.shape = 10,10
interp = 'bilinear';
plt.subplot(211, axisbg='g')
plt.title('blue should be up')
plt.imshow(x, origin='upper', interpolation=interp)
plt.subplot(212, axisbg='y')
plt.title('blue should be down')
plt.imshow(x, origin='lower', interpolation=interp)
plt.show()
def testGridOrigin():
fig = plt.figure()
grid2 = ImageGrid(fig, 111,
nrows_ncols = (1, 2),
direction="row",
axes_pad = 0.05,
add_all=True,
label_mode = "1",
share_all = True,
cbar_location="right",
cbar_mode="single",
cbar_size="10%",
cbar_pad=0.05,
)
x = np.arange(100.0); x.shape = 10,10
interp = 'bilinear';
for ax, _orig in zip(grid2, ['upper', 'lower']):
print _orig
ax.imshow(x, origin = _orig, interpolation=interp)
plt.show()
这是版本
>>> matplotlib.__version__
'1.3.1'
更新
我试过1.4.3。它有同样的问题。