You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Out[67]: [<matplotlib.lines.Line2D object at 0x92a6b6c>]
80
+
```
81
+
82
+
你会看到 x 轴标签重合到一起。
83
+
84
+

85
+
86
+
另一个麻烦是,如果你将鼠标悬停在窗口上,并在 x 和 y 坐标处查看 matplotlib 工具栏([交互式导航](http://matplotlib.org/users/navigation_toolbar.html#navigation-toolbar))的右下角,您会看到 x 位置的格式与刻度标签的格式相同, 例如,“Dec 2004”。 我们想要的是工具栏中的位置具有更高的精确度,例如,鼠标悬停在上面时给我们确切的日期。 为了解决第一个问题,我们可以使用[`matplotlib.figure.Figure.autofmt_xdate()`](http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.autofmt_xdate)。修复第二个问题,我们可以使用`ax.fmt_xdata`属性,该属性可以设置为任何接受标量并返回字符串的函数。 matplotlib 有一些内置的日期格式化器,所以我们将使用其中的一个。
87
+
88
+
```py
89
+
plt.close('all')
90
+
fig, ax = plt.subplots(1)
91
+
ax.plot(r.date, r.close)
92
+
93
+
# rotate and align the tick labels so they look better
94
+
fig.autofmt_xdate()
95
+
96
+
# use a more precise date string for the x axis locations in the
0 commit comments