Skip to content

Commit e55bdea

Browse files
committed
pie_demo2: illustrate use of returned values to make it readable
1 parent f093e22 commit e55bdea

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

examples/pylab_examples/pie_demo2.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,32 @@
2929

3030
subplot(the_grid[0, 1])
3131

32-
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
32+
pie(fracs, explode=explode, labels=labels, autopct='%.0f%%', shadow=True)
3333

3434
subplot(the_grid[1, 0])
3535

36-
pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True, radius=0.5)
36+
patches, texts, autotexts = pie(fracs, labels=labels,
37+
autopct='%.0f%%',
38+
shadow=True, radius=0.5)
39+
40+
# Make the labels on the small plot easier to read.
41+
for t in texts:
42+
t.set_size('smaller')
43+
for t in autotexts:
44+
t.set_size('x-small')
45+
autotexts[0].set_color('y')
3746

3847
subplot(the_grid[1, 1])
3948

40-
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True,
41-
radius=0.5)
49+
patches, texts, autotexts = pie(fracs, explode=explode,
50+
labels=labels, autopct='%.0f%%',
51+
shadow=False, radius=0.5)
52+
# Turn off shadow for tiny plot
53+
# with exploded slice.
54+
for t in texts:
55+
t.set_size('smaller')
56+
for t in autotexts:
57+
t.set_size('x-small')
58+
autotexts[0].set_color('y')
4259

4360
show()

0 commit comments

Comments
 (0)