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.| kind | Description |
| line | Line chart. |
| bar | Vertical column chart. |
| barh | Horizontal column chart. |
| hist | Histogram. |
| box | Box plot. |
| kde | Kernel density estimation |
| density | Same as kde. |
| area | Area plot. |
| pie | Pie chart. |
| scatter | Scatter chart. |
| hexbin | Hexbin plot. |
In addition to the parameters in the preceding table, the
plot function includes the following parameters to simplify plotting.| Parameter | Description |
| xlabel | The name of the x-axis. |
| ylabel | The name of the y-axis. |
| xlabelsize | The font size of the x-axis name. |
| ylabelsize | The font size of the y-axis name. |
| labelsize | The font size of the axis names. |
| title | The title. |
| titlesize | The font size of the title. |
| annotate | Specifies whether to annotate values. |
Is this page helpful?