diff --git a/doc/source/visualization.rst b/doc/source/visualization.rst index 076870eff1761..1d2e996934f76 100644 --- a/doc/source/visualization.rst +++ b/doc/source/visualization.rst @@ -126,7 +126,7 @@ These include: * :ref:`'hist' ` for histogram * :ref:`'kde' ` or ``'density'`` for density plots * :ref:`'area' ` for area plots -* :ref:`'scatter' ` for scatter plots +* :ref:`'scatter' ` for scatter plots * :ref:`'hexbin' ` for hexagonal bin plots * :ref:`'pie' ` for pie plots @@ -427,6 +427,52 @@ To produce an unstacked plot, pass ``stacked=False``. Alpha value is set to 0.5 @savefig area_plot_unstacked.png df.plot(kind='area', stacked=False); +.. _visualization.scatter: + +Scatter Plot +~~~~~~~~~~~~ + +.. versionadded:: 0.13 + +You can create scatter plots with ``DataFrame.plot`` by passing ``kind='scatter'``. +Scatter plot requires numeric columns for x and y axis. +These can be specified by ``x`` and ``y`` keywords each. + +.. ipython:: python + :suppress: + + np.random.seed(123456) + plt.figure() + +.. ipython:: python + + df = DataFrame(rand(50, 4), columns=['a', 'b', 'c', 'd']) + + @savefig scatter_plot.png + df.plot(kind='scatter', x='a', y='b'); + +To plot multiple column groups in a single axes, repeat ``plot`` method specifying target ``ax``. +It is recommended to specify ``color`` and ``label`` keywords to distinguish each groups. + +.. ipython:: python + + ax = df.plot(kind='scatter', x='a', y='b', + color='DarkBlue', label='Group 1'); + @savefig scatter_plot_repeated.png + df.plot(kind='scatter', x='c', y='d', + color='DarkGreen', label='Group 2', ax=ax); + +You can pass other keywords supported by matplotlib ``scatter``. +Below example shows a bubble chart using a dataframe column values as bubble size. + +.. ipython:: python + + @savefig scatter_plot_bubble.png + df.plot(kind='scatter', x='a', y='b', s=df['c']*200); + +See the :meth:`scatter ` method and the +`matplotlib scatter documenation `__ for more. + .. _visualization.hexbin: Hexagonal Bin Plot