我想从我的x轴标签中删除秒,因为它们是不必要的.
此外,我想中心对齐刻度标签,而不是让它们位于刻度线的左侧.
有关如何做到这一点的任何建议?
以下是我使用的一些代码,如果这有帮助的话
fig=plt.figure()
ax=fig.add_subplot(111)
line1 = plot(table.index,table[data],color=colors[0])
fig.autofmt_xdate(rotation=0)
tickFormat = matplotlib.ticker.LinearLocator(numticks=5)
ax.xaxis.set_major_locator(tickFormat)
Run Code Online (Sandbox Code Playgroud)

from matplotlib.dates import DateFormatter
formatter = DateFormatter('%H:%M')
plt.gcf().axes[0].xaxis.set_major_formatter(formatter)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3639 次 |
| 最近记录: |