matplotlib.pyplot.plot_date#
- matplotlib.pyplot.plot_date(x,y,fmt='o',tz=None,xdate=True,ydate=False,*,data=None,**kwargs)[source]#
[Deprecated] Plot coercing the axis to treat floats as dates.
Deprecated since version 3.9:This method exists for historic reasons and will be removed in version 3.11.
datetime
-like data should directly be plotted usingplot
.If you need to plot plain numeric data asMatplotlib date format orneed to set a timezone, call
ax.xaxis.axis_date
/ax.yaxis.axis_date
beforeplot
. SeeAxis.axis_date
.
Similar to
plot
, this plotsy vs.x as lines or markers.However, the axis labels are formatted as dates depending onxdateandydate. Note thatplot
will work withdatetime
andnumpy.datetime64
objects without resorting to this method.- Parameters:
- x, yarray-like
The coordinates of the data points. Ifxdate orydate isTrue, the respective valuesx ory are interpreted asMatplotlib dates.
- fmtstr, optional
The plot format string. For details, see the correspondingparameter in
plot
.- tztimezone string or
datetime.tzinfo
, default:rcParams["timezone"]
(default:'UTC'
) The time zone to use in labeling dates.
- xdatebool, default: True
IfTrue, thex-axis will be interpreted as Matplotlib dates.
- ydatebool, default: False
IfTrue, they-axis will be interpreted as Matplotlib dates.
- Returns:
- list of
Line2D
Objects representing the plotted data.
- list of
- Other Parameters:
- dataindexable object, optional
If given, the following parameters also accept a string
s
, which isinterpreted asdata[s]
ifs
is a key indata
:x,y
- **kwargs
Keyword arguments control the
Line2D
properties:Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
CapStyle
or {'butt', 'projecting', 'round'}JoinStyle
or {'miter', 'round', 'bevel'}sequence of floats (on/off ink in points) or (None, None)
(2, N) array or two 1D arrays
{'default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'}, default: 'default'
{'full', 'left', 'right', 'bottom', 'top', 'none'}
color or None
str
bool
object
{'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
float
marker style string,
Path
orMarkerStyle
float
markersize
orms
float
None or int or (int, int) or slice or list[int] or float or (float, float) or list[bool]
bool
list of
AbstractPathEffect
float or callable[[Artist, Event], tuple[bool, dict]]
float
bool
(scale: float, length: float, randomness: float)
bool or None
CapStyle
or {'butt', 'projecting', 'round'}JoinStyle
or {'miter', 'round', 'bevel'}unknown
str
bool
1D array
1D array
float
See also
matplotlib.dates
Helper functions on dates.
matplotlib.dates.date2num
Convert dates to num.
matplotlib.dates.num2date
Convert num to dates.
matplotlib.dates.drange
Create an equally spaced sequence of dates.
Notes
Note
This is thepyplot wrapper for
axes.Axes.plot_date
.If you are using custom date tickers and formatters, it may benecessary to set the formatters/locators after the call to
plot_date
.plot_date
will set the default tick locator toAutoDateLocator
(if the tick locator is not already set to aDateLocator
instance) and the default tick formatter toAutoDateFormatter
(if the tick formatter is not already set to aDateFormatter
instance).Deprecated since version 3.9:Use plot instead.