Skip to content

Commit dd8c8fc

Browse files
committed
Merge pull request #8069 from sinhrks/scatter_doc
DOC: Add scatter to visualization.rst
2 parents 6a4399d + f15e5ea commit dd8c8fc

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

doc/source/visualization.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ These include:
126126
* :ref:`'hist' <visualization.hist>` for histogram
127127
* :ref:`'kde' <visualization.kde>` or ``'density'`` for density plots
128128
* :ref:`'area' <visualization.area_plot>` for area plots
129-
* :ref:`'scatter' <visualization.scatter_matrix>` for scatter plots
129+
* :ref:`'scatter' <visualization.scatter>` for scatter plots
130130
* :ref:`'hexbin' <visualization.hexbin>` for hexagonal bin plots
131131
* :ref:`'pie' <visualization.pie>` for pie plots
132132

@@ -427,6 +427,52 @@ To produce an unstacked plot, pass ``stacked=False``. Alpha value is set to 0.5
427427
@savefig area_plot_unstacked.png
428428
df.plot(kind='area', stacked=False);
429429
430+
.. _visualization.scatter:
431+
432+
Scatter Plot
433+
~~~~~~~~~~~~
434+
435+
.. versionadded:: 0.13
436+
437+
You can create scatter plots with ``DataFrame.plot`` by passing ``kind='scatter'``.
438+
Scatter plot requires numeric columns for x and y axis.
439+
These can be specified by ``x`` and ``y`` keywords each.
440+
441+
.. ipython:: python
442+
:suppress:
443+
444+
np.random.seed(123456)
445+
plt.figure()
446+
447+
.. ipython:: python
448+
449+
df = DataFrame(rand(50, 4), columns=['a', 'b', 'c', 'd'])
450+
451+
@savefig scatter_plot.png
452+
df.plot(kind='scatter', x='a', y='b');
453+
454+
To plot multiple column groups in a single axes, repeat ``plot`` method specifying target ``ax``.
455+
It is recommended to specify ``color`` and ``label`` keywords to distinguish each groups.
456+
457+
.. ipython:: python
458+
459+
ax = df.plot(kind='scatter', x='a', y='b',
460+
color='DarkBlue', label='Group 1');
461+
@savefig scatter_plot_repeated.png
462+
df.plot(kind='scatter', x='c', y='d',
463+
color='DarkGreen', label='Group 2', ax=ax);
464+
465+
You can pass other keywords supported by matplotlib ``scatter``.
466+
Below example shows a bubble chart using a dataframe column values as bubble size.
467+
468+
.. ipython:: python
469+
470+
@savefig scatter_plot_bubble.png
471+
df.plot(kind='scatter', x='a', y='b', s=df['c']*200);
472+
473+
See the :meth:`scatter <matplotlib.axes.Axes.scatter>` method and the
474+
`matplotlib scatter documenation <http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter>`__ for more.
475+
430476
.. _visualization.hexbin:
431477

432478
Hexagonal Bin Plot

0 commit comments

Comments
 (0)