Skip to content

Commit 1ac2dec

Browse files
author
Tom Augspurger
committed
Merge pull request #8391 from TomAugspurger/square-pie
DOC: Use square figsize for pie plots
2 parents a0bef0b + 3810417 commit 1ac2dec

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

doc/source/visualization.rst

+12-8
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ A ``ValueError`` will be raised if there are any negative values in your data.
621621
series = Series(3 * rand(4), index=['a', 'b', 'c', 'd'], name='series')
622622
623623
@savefig series_pie_plot.png
624-
series.plot(kind='pie')
624+
series.plot(kind='pie', figsize=(6, 6))
625+
626+
For pie plots it's best to use square figures, one's with an equal aspect ratio. You can create the
627+
figure with equal width and height, or force the aspect ratio to be equal after plotting by
628+
calling ``ax.set_aspect('equal')`` on the returned ``axes`` object.
625629

626630
Note that pie plot with :class:`DataFrame` requires that you either specify a target column by the ``y``
627631
argument or ``subplots=True``. When ``y`` is specified, pie plot of selected column
@@ -639,7 +643,7 @@ A legend will be drawn in each pie plots by default; specify ``legend=False`` to
639643
df = DataFrame(3 * rand(4, 2), index=['a', 'b', 'c', 'd'], columns=['x', 'y'])
640644
641645
@savefig df_pie_plot.png
642-
df.plot(kind='pie', subplots=True)
646+
df.plot(kind='pie', subplots=True, figsize=(8, 4))
643647
644648
You can use the ``labels`` and ``colors`` keywords to specify the labels and colors of each wedge.
645649

@@ -662,7 +666,7 @@ Also, other keywords supported by :func:`matplotlib.pyplot.pie` can be used.
662666
663667
@savefig series_pie_plot_options.png
664668
series.plot(kind='pie', labels=['AA', 'BB', 'CC', 'DD'], colors=['r', 'g', 'b', 'c'],
665-
autopct='%.2f', fontsize=20)
669+
autopct='%.2f', fontsize=20, figsize=(6, 6))
666670
667671
If you pass values whose sum total is less than 1.0, matplotlib draws a semicircle.
668672

@@ -676,7 +680,7 @@ If you pass values whose sum total is less than 1.0, matplotlib draws a semicirc
676680
series = Series([0.1] * 4, index=['a', 'b', 'c', 'd'], name='series2')
677681
678682
@savefig series_pie_plot_semi.png
679-
series.plot(kind='pie')
683+
series.plot(kind='pie', figsize=(6, 6))
680684
681685
See the `matplotlib pie documenation <http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie>`__ for more.
682686

@@ -1113,16 +1117,16 @@ or columns needed, given the other.
11131117
.. ipython:: python
11141118
11151119
@savefig frame_plot_subplots_layout.png
1116-
df.plot(subplots=True, layout=(2, 3), figsize=(6, 6));
1120+
df.plot(subplots=True, layout=(3, 2), figsize=(6, 6), sharex=False);
11171121
11181122
The above example is identical to using
11191123

11201124
.. ipython:: python
11211125
1122-
df.plot(subplots=True, layout=(-1, 3), figsize=(6, 6));
1126+
df.plot(subplots=True, layout=(3, -1), figsize=(6, 6), sharex=False);
11231127
1124-
The required number of rows (2) is inferred from the number of series to plot
1125-
and the given number of columns (3).
1128+
The required number of columns (2) is inferred from the number of series to plot
1129+
and the given number of rows (3).
11261130

11271131
Also, you can pass multiple axes created beforehand as list-like via ``ax`` keyword.
11281132
This allows to use more complicated layout.

0 commit comments

Comments
 (0)