Python Matplotlib LocatableAxes xtick标签
我尝试在网格中绘制多个图形,并标记其x和y记号,即:Python Matplotlib LocatableAxes xtick标签,python,matplotlib,Python,Matplotlib,我尝试在网格中绘制多个图形,并标记其x和y记号,即: import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import ImageGrid import numpy as np im = np.arange(100) im.shape = 10, 10 fig = plt.figure(1, (4., 4.)) grid = ImageGrid(fig, 111, # similar to subplot(111)
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy as np
im = np.arange(100)
im.shape = 10, 10
fig = plt.figure(1, (4., 4.))
grid = ImageGrid(fig, 111, # similar to subplot(111)
nrows_ncols=(2, 2), # creates 2x2 grid of axes
axes_pad=0.1, # pad between axes in inch.
)
for i in range(4):
grid[i].imshow(im) # The AxesGrid object work as a list of axes.
grid[i].set_xticks(np.arange(im.shape[0]))
grid[i].set_yticks(np.arange(im.shape[0]))
plt.show()
我如何将这些记号标签改为[“a”、“b”、“c”、“j”]
我尝试了grid[I]。设置了xtickslabels()
,但得到了错误:AttributeError:'locatablexes'对象没有属性“set\xtickslabels”
它是set\xticklabels
,例如:
grid[i].set_xticklabels(["a","b","c"])
你们错了,方法的正确名称是
set\xticklabels
,这太愚蠢了。