Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7926105

Browse files
committed
Cleanup and move pie_demo
1 parent 6c5c108 commit 7926105

2 files changed

Lines changed: 32 additions & 30 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Demo of a basic pie chart plus a few additional features.
3+
4+
In addition to the basic pie chart, this demo shows a few optional features:
5+
6+
* slice labels
7+
* auto-labeling the percentage
8+
* offsetting a slice with "explode"
9+
* drop-shadow
10+
* custom start angle
11+
12+
13+
Note about the custom start angle:
14+
15+
The default ``startangle`` is 0, which would start the "Frogs" slice on the
16+
x-axis. This example sets ``startangle = 90`` such that everything is rotated
17+
counter-clockwise by 90 degrees, the frog slice starts on the positive y-axis.
18+
"""
19+
import matplotlib.pyplot as plt
20+
21+
22+
# The slices will be ordered and plotted counter-clockwise.
23+
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
24+
sizes = [15, 30, 45, 10]
25+
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
26+
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
27+
28+
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
29+
autopct='%1.1f%%', shadow=True, startangle=90)
30+
# Set aspect ratio to be equal so that pie is drawn as a circle.
31+
plt.axis('equal')
32+
plt.show()

examples/pylab_examples/pie_demo.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)