| 6718 | |
| 6719 | @image_comparison(['pie_frame_grid.png'], style='mpl20') |
| 6720 | def test_pie_frame_grid(): |
| 6721 | # The slices will be ordered and plotted counter-clockwise. |
| 6722 | labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' |
| 6723 | sizes = [15, 30, 45, 10] |
| 6724 | colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] |
| 6725 | # only "explode" the 2nd slice (i.e. 'Hogs') |
| 6726 | explode = (0, 0.1, 0, 0) |
| 6727 | |
| 6728 | plt.pie(sizes, explode=explode, labels=labels, colors=colors, |
| 6729 | autopct='%1.1f%%', shadow=True, startangle=90, |
| 6730 | wedgeprops={'linewidth': 0}, |
| 6731 | frame=True, center=(2, 2)) |
| 6732 | |
| 6733 | plt.pie(sizes[::-1], explode=explode, labels=labels, colors=colors, |
| 6734 | autopct='%1.1f%%', shadow=True, startangle=90, |
| 6735 | wedgeprops={'linewidth': 0}, |
| 6736 | frame=True, center=(5, 2)) |
| 6737 | |
| 6738 | plt.pie(sizes, explode=explode[::-1], labels=labels, colors=colors, |
| 6739 | autopct='%1.1f%%', shadow=True, startangle=90, |
| 6740 | wedgeprops={'linewidth': 0}, |
| 6741 | frame=True, center=(3, 5)) |
| 6742 | # Set aspect ratio to be equal so that pie is drawn as a circle. |
| 6743 | plt.axis('equal') |
| 6744 | |
| 6745 | |
| 6746 | @image_comparison(['pie_rotatelabels_true.png'], style='mpl20') |