pyspark.pandas.DataFrame.plot.line#

plot.line(x=None, y=None, **kwargs)#

Plot DataFrame/Series as lines.

This function is useful to plot lines using Series’s values as coordinates.

Parameters
xint or str, optional

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.

yint, str, or list of them, optional

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.

**kwds

Keyword arguments to pass on to Series.plot() or DataFrame.plot().

Returns
plotly.graph_objs.Figure

Return an custom object when backend!=plotly. Return an ndarray when subplots=True (matplotlib-only).

See also

plotly.express.line

Plot y versus x as lines and/or markers (plotly).

matplotlib.pyplot.plot

Plot y versus x as lines and/or markers (matplotlib).

Examples

Basic plot.

For Series:

>>> s = ps.Series([1, 3, 2])
>>> s.plot.line()  

For DataFrame:

The following example shows the populations for some animals over the years.

>>> df = ps.DataFrame({'pig': [20, 18, 489, 675, 1776],
...                    'horse': [4, 25, 281, 600, 1900]},
...                   index=[1990, 1997, 2003, 2009, 2014])
>>> df.plot.line()  

The following example shows the relationship between both populations.

>>> df = ps.DataFrame({'pig': [20, 18, 489, 675, 1776],
...                    'horse': [4, 25, 281, 600, 1900]},
...                   index=[1990, 1997, 2003, 2009, 2014])
>>> df.plot.line(x='pig', y='horse')