【发布时间】:2017-01-20 12:17:33
【问题描述】:
我正在尝试在网格中绘制多个图形,并标记它们的 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)
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].set_xtickslabels(),但我得到了错误:AttributeError: 'LocatableAxes' object has no attribute 'set_xtickslabels'
【问题讨论】:
-
你错了正确的方法名是
set_xticklabels
标签: python matplotlib