Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →In Matplotlib 3.11, plot_date has been removed. Plot Python datetime or NumPy datetime64 values directly with plot; Matplotlib handles date conversion and usually chooses date-aware ticks automatically. Use date2num or num2date only when you specifically need Matplotlib’s numeric date representation.
Replace plot_date with plot
plot_date was discouraged starting in Matplotlib 3.5, deprecated in 3.9, and removed in 3.11. The Matplotlib 3.11.0 API changes direct users to plot datetime-like data with plot instead. Matplotlib 3.11.0 API changes
As an Amazon Associate I earn from qualifying purchases.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(dates, values, marker="o")
plt.show()
Here, dates can contain Python datetime objects or NumPy datetime64 values. Matplotlib’s date converter handles them, so ordinary date plotting does not require a preliminary conversion to floats. Plotting dates and strings
Format date labels and control tick spacing
A locator chooses where ticks go; a formatter chooses the text displayed at those ticks. Configure each separately when Matplotlib’s automatic choices do not suit the chart.
#1 Best Overall
import matplotlib.dates as mdates
ax.xaxis.set_major_locator(mdates.DayLocator(interval=1))
ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
fig.autofmt_xdate()
DayLocator(interval=1) requests a tick each day, while DateFormatter("%Y-%m-%d") displays labels such as 2026-10-10. Other strftime-style formats include "%b %d" for abbreviated month and day. The actual tick schedule can depend on the date range and locator; consult the date plotting guide for locator and formatter examples.
When labels overlap
- Reduce the number of ticks by increasing the locator interval or selecting a locator appropriate to the time span.
- Rotate labels with
fig.autofmt_xdate()orax.tick_params(axis="x", rotation=70). - For spans with repeated year or month text, use Matplotlib’s concise date formatter to reduce redundant parts of labels. Plotting dates and strings
A date locator is preferable to manually assigning a string to every tick when the axis represents a changing date range: locator positions remain date-aware as the plotted range changes.
Rank #2
Convert dates to and from Matplotlib date numbers
Matplotlib date numbers are floating-point values measured in days from an epoch, not Unix timestamps in seconds. The default epoch is 1970-01-01T00:00:00. date2num converts dates to Matplotlib numbers; num2date converts numbers back to date values.
import matplotlib.dates as mdates
number = mdates.date2num(dates[0])
recovered_date = mdates.num2date(number)
Use these conversions when another calculation or interface specifically needs numeric Matplotlib date values. For plotting date-like inputs, direct use of ax.plot(dates, values) is simpler.
Plot numeric date values or set a timezone
If x values are already numeric Matplotlib date numbers, tell the axis to interpret them as dates before plotting. Otherwise, plain floats may be treated as ordinary numeric coordinates.
ax.xaxis.axis_date()
ax.plot(date_numbers, values)
Matplotlib’s 3.11 API changes also point to axis_date when configuring a date axis or timezone. A numeric date value of zero represents the configured epoch when the axis is using date units. Matplotlib 3.11.0 API changes
Check precision for fine-grained timestamps
Floating-point date values have finite precision, and the precision guidance notes that it depends on how close dates are to the epoch. Most daily and hourly charts do not need an epoch change. If microsecond precision is important for modern dates, see Matplotlib’s date precision and epochs guide.
If you change the epoch, do it before any date operations. Changing it after date conversion or plotting has begun raises a RuntimeError. The default epoch and its configuration are documented in the rcParams reference.
Quick Recap
Best Value
Troubleshoot unexpected date axes
- ImportError or missing function: If code calls
plot_dateunder Matplotlib 3.11 or later, replace it withplotand pass date-like values directly. - Unexpected numeric tick labels: Confirm the x values are date-like, or call
ax.xaxis.axis_date()before plotting numeric Matplotlib date values. - Overlapping labels: Change the locator interval, use a different date locator, or rotate labels.
- Insufficient microsecond precision: Check the epoch guidance and configure the epoch before performing date operations.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




