-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Documentation: APIfiles in lib/ and doc/apifiles in lib/ and doc/apistatus: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.
Description
Problem
I am trying to create a figure with dates on the x-axis.
import matplotlib.pyplot as plt
import pandas as pd
fig, ax = plt.subplots()
dt = pd.to_datetime('1980-01-01 00:00:00')
Matplotlib already supports entering datetime as x-coordinate for vertical lines:
ax.axvline(dt)
But it does not allow me to use datetimes as xmin and xmax for horizontal lines:
ax.axhline(0, dt)
File "/home/miniconda3/envs/stata/lib/python3.12/site-packages/matplotlib/axes/_axes.py", line 773, in axhline
self._check_no_units([xmin, xmax], ['xmin', 'xmax'])
File "/home/miniconda3/envs/stata/lib/python3.12/site-packages/matplotlib/axes/_axes.py", line 863, in _check_no_units
raise ValueError(f"{name} must be a single scalar value, "
ValueError: xmin must be a single scalar value, but got 1980-01-01 00:00:00
Proposed solution
No response
Metadata
Metadata
Assignees
Labels
Documentation: APIfiles in lib/ and doc/apifiles in lib/ and doc/apistatus: needs clarificationIssues that need more information to resolve.Issues that need more information to resolve.