|
6 | 6 | like autolabeling the percentage, offsetting a slice with "explode" |
7 | 7 | and adding a shadow, in different sizes. |
8 | 8 |
|
9 | | -Requires matplotlib0-0.70 or later |
10 | | -
|
11 | 9 | """ |
12 | 10 | from pylab import * |
13 | | -import matplotlib.gridspec as gridspec |
14 | | -import matplotlib.pyplot as pyplot |
15 | | - |
| 11 | +from matplotlib.gridspec import GridSpec |
16 | 12 |
|
17 | 13 | # Some data |
18 | 14 |
|
|
21 | 17 |
|
22 | 18 | explode=(0, 0.05, 0, 0) |
23 | 19 |
|
24 | | - |
25 | 20 | # Make square figures and axes |
26 | 21 |
|
27 | | -the_grid = matplotlib.gridspec.GridSpec(2, 2) |
| 22 | +the_grid = GridSpec(2, 2) |
28 | 23 |
|
29 | 24 | figure(1, figsize=(6,6)) |
30 | 25 |
|
31 | | -pyplot.subplot(the_grid[0, 0]) |
| 26 | +subplot(the_grid[0, 0]) |
32 | 27 |
|
33 | | -pie(fracs, labels = labels, autopct = '%1.1f%%', shadow = True) |
| 28 | +pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True) |
34 | 29 |
|
35 | | -pyplot.subplot(the_grid[0, 1]) |
| 30 | +subplot(the_grid[0, 1]) |
36 | 31 |
|
37 | | -pie(fracs, explode=explode, labels = labels, autopct = '%1.1f%%', shadow = True) |
| 32 | +pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True) |
38 | 33 |
|
39 | | -pyplot.subplot(the_grid[1, 0]) |
| 34 | +subplot(the_grid[1, 0]) |
40 | 35 |
|
41 | | -pie(fracs, labels = labels, autopct = '%1.1f%%', shadow = True, radius = 0.5) |
| 36 | +pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True, radius=0.5) |
42 | 37 |
|
43 | | -pyplot.subplot(the_grid[1, 1]) |
| 38 | +subplot(the_grid[1, 1]) |
44 | 39 |
|
45 | | -pie(fracs, explode=explode, labels = labels, autopct = '%1.1f%%', shadow = True, |
46 | | - radius = 0.5) |
| 40 | +pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True, |
| 41 | + radius=0.5) |
47 | 42 |
|
48 | 43 | show() |
0 commit comments