October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Plot Dates in Matplotlib: Scatter Points and Multiple Lines

Matplotlib removed plot_date in version 3.11. Use plot with datetime-like values for scatter points or multiple date-based lines, and adjust date ticks only when the automatic labels need control.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In current Matplotlib, use plot instead of plot_date for date-based scatter charts and time series. Pass datetime.datetime or numpy.datetime64 values directly; Matplotlib converts them and selects date-aware ticks automatically. For points without connecting lines, set linestyle='none'; for multiple series, plot each series against the same dates and give it a label.

Why plot_date examples no longer work

Matplotlib discouraged plot_date starting in version 3.5, deprecated it in 3.9, and removed it in 3.11. For current code, replace ax.plot_date(dates, values, ...) with ax.plot(dates, values, ...), keeping any marker and line styling as explicit keyword arguments. The Matplotlib 3.11 migration notes say that “datetime-like data should directly be plotted using plot.” See the Matplotlib 3.11 API changes and the 3.9 deprecation notes.

As an Amazon Associate I earn from qualifying purchases.

Make a scatter chart with dates

Use plot with a marker and no line. This example uses NumPy dates; sequences of datetime.datetime values work as well.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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()

The marker sets the point symbol, while linestyle='none' prevents Matplotlib from drawing connecting segments. The public plot API supports these styling options and date-valued data.

Plot multiple lines against the same dates

Call plot once per series, reusing the date array. Choose a distinct label for each line so the legend identifies it.

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()

Each y series must correspond to the dates it is plotted against. You can also provide multiple x/y pairs in a single plot call; repeated calls are often easier to read when each series needs its own label or styling. See the plot function documentation.

How date conversion and tick labels work

For datetime.datetime and numpy.datetime64 inputs, Matplotlib’s date unit converter handles the conversion and supplies date-aware tick locators and formatters. The defaults are AutoDateLocator and AutoDateFormatter, so start with automatic ticks before adding manual formatting. The matplotlib.dates documentation describes the available date tools.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When to use axis_date

For ordinary datetime-like inputs, you normally do not need to call axis_date. Use ax.xaxis.axis_date (or ax.yaxis.axis_date) when numeric values should be interpreted as date coordinates, or when configuring a timezone for that axis. Set this up before plotting. Numeric coordinates must use Matplotlib’s date-day representation; they are not ordinary date strings or Unix timestamps by default. The dates and units guide explains the conversion behavior.

When to set locators and formatters

If the automatic tick spacing or labels do not fit the chart, use date locators such as MonthLocator or YearLocator, and formatters such as DateFormatter. ConciseDateFormatter can reduce repeated date components and may make rotated labels unnecessary. You can set axis limits with datetime-like values; if you set numeric limits, use Matplotlib date-day coordinates. The date tick labels example shows locator and formatter usage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Date precision: when the epoch matters

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, with precision decreasing farther away. For sub-microsecond resolution, the documentation recommends floating-point seconds rather than datetime-like values. If you need to retain datetime-like values at microsecond precision for dates far from the default epoch, set a closer epoch before converting any dates. Details are in the date API documentation.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.