iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
plot_date is no longer available in current Matplotlib: it was removed in Matplotlib 3.11. Use plot with your date values instead. Matplotlib recognizes datetime.datetime and numpy.datetime64 values automatically, so you can create marker-only scatter charts and multiple date-based lines without manually converting dates.
Replace plot_date with plot
Matplotlib discouraged plot_date starting in 3.5, deprecated it in 3.9, and removed it in 3.11. The migration is direct: change ax.plot_date(dates, values, ...) to ax.plot(dates, values, ...), and specify marker and line styling explicitly. Matplotlib’s 3.11 migration notes say that “datetime-like data should directly be plotted using plot.” Matplotlib 3.11 API changes and the 3.9 deprecation notice document the change.
Make a scatter chart with dates
For a scatter-like chart, use a marker and disable the connecting line with linestyle='none'. The following example uses a NumPy array of dates:
Recommended Free Tools
import matplotlib.pyplot as plt
import numpy as np
dates = np.array(['2025-01-01', '2025-02-01', '2025-03-01'], dtype='datetime64[D]')
values = [4, 7, 5]
fig, ax = plt.subplots()
ax.plot(dates, values, marker='o', linestyle='none', label='Observations')
ax.set_xlabel('Date')
ax.set_ylabel('Value')
ax.legend()
plt.show()
You can use datetime.datetime values in place of the NumPy dates. Matplotlib’s date unit conversion handles both types automatically and applies date-aware tick handling; explicit conversion is normally unnecessary. The date and string plotting guide explains the conversion behavior.
#1 Best Overall
Plot multiple lines against the same dates
Call plot once per series, using the same date values and a distinct label for each line. Markers are optional; omit them if you want lines only.
fig, ax = plt.subplots()
ax.plot(dates, series_a, marker='o', label='Series A')
ax.plot(dates, series_b, marker='s', label='Series B')
ax.set_xlabel('Date')
ax.set_ylabel('Value')
ax.legend()
plt.show()
The legend uses each series’ label. Matplotlib’s plot function also supports multiple x/y pairs in one call; separate calls are often easier to read when each series needs its own styling or label. See the plot API for supported call forms.
Rank #2
Choose how to configure date axes and ticks
| Approach | When to use it | What it controls |
|---|---|---|
plot with datetime-like values |
Ordinary charts whose x or y data are datetime.datetime or numpy.datetime64. |
Matplotlib converts the values and selects date-aware ticks and labels automatically. |
axis_date before plotting |
Input consists of numeric values that represent dates, or you need to configure the axis timezone. | Marks the selected axis as a date axis. Use ax.xaxis.axis_date or ax.yaxis.axis_date before calling plot. |
| Explicit date locators and formatters | Automatic tick positions or labels do not suit the chart. | Use date locators such as MonthLocator or YearLocator and formatters such as DateFormatter. ConciseDateFormatter can reduce repeated date components. |
Matplotlib’s defaults, AutoDateLocator and AutoDateFormatter, are a useful starting point. For examples of setting date ticks and labels, consult the date tick labels gallery. Axis limits can be supplied as datetime-like values; numeric limits must use Matplotlib’s date-day coordinates. More detail is in the dates API documentation.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesAccount for date precision when plotting fine-grained data
Matplotlib represents dates internally as floating-point days from the default epoch, 1970-01-01 UTC. Its documentation says microsecond accuracy is achievable for dates approximately 70 years on either side of that epoch; precision declines farther away. For sub-microsecond resolution, use floating-point seconds rather than datetime-like values. If you must retain datetime-like values at microsecond precision for dates far from the default epoch, set a closer epoch before converting dates. See Matplotlib’s dates API and date unit documentation.
Quick Recap
Best Value
Common migration errors
- Calling
plot_datein Matplotlib 3.11 or later: replace it withplot; the former API was removed. - Getting connected points instead of a scatter-like chart: specify
marker='o'andlinestyle='none'. - Getting an unhelpful legend: give each series a distinct
labeland callax.legend(). - Passing numeric date coordinates without a date axis: call
ax.xaxis.axis_date()(or the corresponding y-axis method) before plotting, and use Matplotlib date-day coordinates for numeric axis limits.
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.

