Plotting

Updated at:

This topic describes the plotting methods for PyODPS DataFrames.

To use the plotting feature, you must install Pandas and Matplotlib.

You can run the pip install matplotlib command in Jupyter to install Matplotlib.

Plotting

  • Single line chart
    >>> from odps.df import DataFrame
    >>> iris = DataFrame(o.get_table('pyodps_iris'))
    >>> %matplotlib inline
    >>> iris.sepalwidth.plot()
    <matplotlib.axes._subplots.AxesSubplot at 0x10c2b3510>
  • Multiple line chart
    >>> iris.plot()
    <matplotlib.axes._subplots.AxesSubplot at 0x10db7e690>
  • Vertical column chart
    >>> iris.groupby('name').sum().plot(kind='bar', x='name', stacked=True, rot=30)
    <matplotlib.axes._subplots.AxesSubplot at 0x10c5f2090>
  • Histogram
    >>> iris.hist(sharex=True)
    array([[<matplotlib.axes._subplots.AxesSubplot object at 0x10e013f90>,
            <matplotlib.axes._subplots.AxesSubplot object at 0x10e2d1c10>],
           [<matplotlib.axes._subplots.AxesSubplot object at 0x10e353f10>,
            <matplotlib.axes._subplots.AxesSubplot object at 0x10e3c4410>]], dtype=object)
The kind parameter specifies the plot type. The following table lists the supported plot types. For more information about the parameters, see pandas.DataFrame.plot.
kindDescription
lineLine chart.
barVertical column chart.
barhHorizontal column chart.
histHistogram.
boxBox plot.
kdeKernel density estimation
densitySame as kde.
areaArea plot.
piePie chart.
scatterScatter chart.
hexbinHexbin plot.
In addition to the parameters in the preceding table, the plot function includes the following parameters to simplify plotting.
ParameterDescription
xlabelThe name of the x-axis.
ylabelThe name of the y-axis.
xlabelsizeThe font size of the x-axis name.
ylabelsizeThe font size of the y-axis name.
labelsizeThe font size of the axis names.
titleThe title.
titlesizeThe font size of the title.
annotateSpecifies whether to annotate values.