난 당신이 x 축 치기 할 생각 :
#!/usr/bin/env python3
import matplotlib
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
data = range(5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(data,data)
ax.xaxis.set_major_locator(MaxNLocator(5, prune='lower'))
ax.yaxis.set_major_locator(MaxNLocator(4))
fig.savefig("1.png")
편집 :
슬픈하지만 사실 :하기 matplotlib가 교차 축 2D 플롯을 위해 의미되지 않았다. 당신은 확실히 두 축에 대한 제로 왼쪽 박스 모서리에있는 경우 내가 직접 거기에 넣어하는 것이 좋습니다보다 : 여기
#!/usr/bin/env python3
import matplotlib
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
data = range(5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(data,data)
ax.xaxis.set_major_locator(MaxNLocator(5, prune='lower'))
ax.yaxis.set_major_locator(MaxNLocator(4, prune='lower'))
fig.tight_layout()
ax.text(-0.01, -0.02,
"0",
horizontalalignment = 'center',
verticalalignment = 'center',
transform = ax.transAxes)
fig.savefig("1.png")
한 수동 제로 위치를 조정할 수 있습니다.
개인적으로 상황에 따라 x 축이나 y 축을 잘라 내고 행복하게 처리합니다.
나는 당신을 이해하지 못한다. 그냥 원하는거야 : pl.gca(). set_yticks ([0.0,0.2, 0.4, 0.6, 0.8, 1.0]) pl.gca(). set_xticks ([0.2, 0.4, 0.6, 0.8, 1.0]) '?? – yoopoo