X轴的短记号在Axes
之下,而长记号在Axes
之上,有可能吗
使用下面的代码,我可以在同一侧绘制次要记号和主要记号,但是我希望0
和5
记号位于绘图上方,而次要记号位于绘图下方
from matplotlib import figure as mpfig
from matplotlib.backends import backend_agg as mpback
fig = mpfig.Figure()
mpback.FigureCanvas(fig)
ax = fig.add_subplot(111)
x = list(range(10))
y = list(range(10))
ax.set_xticks(list(range(0, 11, 5)))
ax.set_xticks(list(range(0, 11, 1)), minor=True)
ax.plot(x, y)
fig.savefig("picture.png")
此代码生成以下图片:
我知道^{
我想避免使用Axes.twinx
的任何技巧,因为它会添加一个新的Axes
对象,这会使绘图更重
Axes.tick_params
应该能够解决这个问题经过努力,这对我很有用:
相关问题 更多 >
编程相关推荐