Soft-deprecate Axes.plot_date() by timhoffm · Pull Request #18346 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/api/next_api_changes/deprecations/18346-TH.rst
2 changes: 1 addition & 1 deletion examples/ticks_and_spines/date_demo_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
y = np.arange(len(dates))

fig, ax = plt.subplots()
ax.plot_date(dates, y ** 2)
ax.plot(dates, y**2, 'o')

# this is superfluous, since the autoscaler should get it right, but
# use date2num and num2date to convert between dates and floats if
Expand Down
2 changes: 1 addition & 1 deletion examples/ticks_and_spines/date_demo_rrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


fig, ax = plt.subplots()
plt.plot_date(dates, s)
plt.plot(dates, s, 'o')
ax.xaxis.set_major_locator(loc)
ax.xaxis.set_major_formatter(formatter)
ax.xaxis.set_tick_params(rotation=30, labelsize=10)
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,18 @@ def plot_date(self, x, y, fmt='o', tz=None, xdate=True, ydate=False,
"""
Plot co-ercing the axis to treat floats as dates.

.. admonition:: Discouraged

This method exists for historic reasons and will be deprecated in
the future.

- ``datetime``-like data should directly be plotted using
`~.Axes.plot`.
- If you need to plot plain numeric data as :ref:`date-format` or
need to set a timezone, call ``ax.xaxis.axis_date`` /
``ax.yaxis.axis_date`` before `~.Axes.plot`. See
`.Axis.axis_date`.

Similar to `.plot`, this plots *y* vs. *x* as lines or markers.
However, the axis labels are formatted as dates depending on *xdate*
and *ydate*. Note that `.plot` will work with `datetime` and
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/dates.py