我有几个子图并想通过ax.tick_params调整轴刻度设置。 一切都正常,但是次要刻度未显示。 这是一个代码示例:
import matplotlib.pyplot as plt
x = np.linspace(0,1,100)
y = x*x
f, (ax1,ax2) = plt.subplots(2, 1)
ax1.tick_params(axis="both", direction="in", which="both", right=False, top=True)
ax2.tick_params(axis="both", direction="in", which="both", right=True, top=False)
ax1.plot(x,y)
ax2.plot(x,-y)
plt.show()
我以为which=both会给我提供次要刻度。然而,我需要添加额外的内容。
plt.minorticks_on()
这使得它们在ax2中可见,但仅限于此。
我该如何解决这个问题?