plot.
line
Plot DataFrame/Series as lines.
This function is useful to plot lines using Series’s values as coordinates.
Columns to use for the horizontal axis. Either the location or the label of the columns to be used. By default, it will use the DataFrame indices.
The values to be plotted. Either the location or the label of the columns to be used. By default, it will use the remaining DataFrame numeric columns.
Keyword arguments to pass on to Series.plot() or DataFrame.plot().
Series.plot()
DataFrame.plot()
matplotlib.axes.Axes
numpy.ndarray
Return an ndarray when subplots=True. Return an custom object when backend!=matplotlib.
subplots=True
backend!=matplotlib
See also
matplotlib.pyplot.plot
Plot y versus x as lines and/or markers.
Examples
Basic plot.
For Series:
>>> s = ks.Series([1, 3, 2]) >>> ax = s.plot.line()
For DataFrame:
The following example shows the populations for some animals over the years.
>>> df = ks.DataFrame({'pig': [20, 18, 489, 675, 1776], ... 'horse': [4, 25, 281, 600, 1900]}, ... index=[1990, 1997, 2003, 2009, 2014]) >>> lines = df.plot.line()
An example with subplots, so an array of axes is returned.
>>> axes = df.plot.line(subplots=True) >>> type(axes) <class 'numpy.ndarray'>
The following example shows the relationship between both populations.
>>> lines = df.plot.line(x='pig', y='horse')