| 6668 | @image_comparison(['pie_center_radius.png'], style='mpl20', |
| 6669 | tol=0.01 if sys.platform == 'darwin' else 0) |
| 6670 | def test_pie_center_radius(): |
| 6671 | # The slices will be ordered and plotted counter-clockwise. |
| 6672 | labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' |
| 6673 | sizes = [15, 30, 45, 10] |
| 6674 | colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] |
| 6675 | explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') |
| 6676 | |
| 6677 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, |
| 6678 | autopct='%1.1f%%', shadow=True, startangle=90, |
| 6679 | wedgeprops={'linewidth': 0}, center=(1, 2), radius=1.5) |
| 6680 | |
| 6681 | plt.annotate("Center point", xy=(1, 2), xytext=(1, 1.3), |
| 6682 | arrowprops=dict(arrowstyle="->", |
| 6683 | connectionstyle="arc3"), |
| 6684 | bbox=dict(boxstyle="square", facecolor="lightgrey")) |
| 6685 | # Set aspect ratio to be equal so that pie is drawn as a circle. |
| 6686 | plt.axis('equal') |
| 6687 | |
| 6688 | |
| 6689 | @image_comparison(['pie_linewidth_2.png'], style='mpl20') |