Skip to content

DOC: Add scatter to visualization.rst #8069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion doc/source/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ These include:
* :ref:`'hist' <visualization.hist>` for histogram
* :ref:`'kde' <visualization.kde>` or ``'density'`` for density plots
* :ref:`'area' <visualization.area_plot>` for area plots
* :ref:`'scatter' <visualization.scatter_matrix>` for scatter plots
* :ref:`'scatter' <visualization.scatter>` for scatter plots
* :ref:`'hexbin' <visualization.hexbin>` for hexagonal bin plots
* :ref:`'pie' <visualization.pie>` for pie plots

Expand Down Expand Up @@ -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 <matplotlib.axes.Axes.scatter>` method and the
`matplotlib scatter documenation <http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter>`__ for more.

.. _visualization.hexbin:

Hexagonal Bin Plot
Expand Down