이 함수를 설명서에서 사용하여 matplotlib과 함께 멋진 플롯을 만듭니다.AxisGrid를 사용하여 플로팅 할 때 MinorLocator 변경
def demo_grid_with_single_cbar(fig):
"""
A grid of 2x2 images with a single colorbar
"""
grid = AxesGrid(fig, 132, # similar to subplot(132)
nrows_ncols = (2, 2),
axes_pad = 0.0,
share_all=True,
label_mode = "L",
cbar_location = "top",
cbar_mode="single",
)
Z, extent = get_demo_image()
for i in range(4):
im = grid[i].imshow(Z, extent=extent, interpolation="nearest")
#plt.colorbar(im, cax = grid.cbar_axes[0])
grid.cbar_axes[0].colorbar(im)
for cax in grid.cbar_axes:
cax.toggle_label(False)
# This affects all axes as share_all = True.
grid.axes_llc.set_xticks([-2, 0, 2])
grid.axes_llc.set_yticks([-2, 0, 2])
마이너 로케이터를 변경하고 싶습니다. 하지만 코드를 변경할 위치가 없습니다. 하나의 그래픽에서 Axes 객체를 조작한다면 어디에 사용합니까? AxesGrid를 사용하면 길을 잃어 버립니다.
majorLocator = MultipleLocator(50)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(10)
ax.yaxis.set_major_locator(majorLocator)
ax.yaxis.set_major_formatter(majorFormatter)
ax.yaxis.set_minor_locator(minorLocator)
문제가 해결 된 후 편집하십시오. 결과는 다음 그림과 같을 것입니다. 작은 눈금을 확인하십시오!
결과는 http://i.stack.imgur.com/o1YPK.png
어쩌면 다른 사람을 추가 할 수 있습니다이 이미지처럼 보일 것입니다. 내 명성 크레딧으로는 충분하지 않기 때문에 그럴 수 없습니다.
어떤 matplotlib 버전을 사용하고 있습니까? – tacaswell
버전 1.1.1rc – elcojon