Note that there are some explanatory texts on larger screens.

plurals
  1. POPlotting a pie-chart in matplotlib at a specific angle with the fracs on the wedges
    primarykey
    data
    text
    <p>I am plotting a piechart with matplotlib using the following code:</p> <pre><code>ax = axes([0.1, 0.1, 0.6, 0.6]) labels = 'Twice Daily', 'Daily', '3-4 times per week', 'Once per week','Occasionally' fracs = [20,50,10,10,10] explode=(0, 0, 0, 0,0.1) patches, texts, autotexts = ax.pie(fracs, labels=labels, explode = explode, autopct='%1.1f%%', shadow =True) proptease = fm.FontProperties() proptease.set_size('xx-small') setp(autotexts, fontproperties=proptease) setp(texts, fontproperties=proptease) rcParams['legend.fontsize'] = 7.0 savefig("pie1") </code></pre> <p>This produces the following piechart. <img src="https://i.stack.imgur.com/kWKOL.png" alt="PieChart 1"></p> <p>However, I want to start the pie-chart with the first wedge on top, the only solution I could find for this was using <a href="https://stackoverflow.com/questions/3816809/how-to-plot-a-pie-chart-with-the-first-wedge-on-top-in-python-matplotlib">this code </a></p> <p>However on using this as below,</p> <pre><code>from pylab import * from matplotlib import font_manager as fm from matplotlib.transforms import Affine2D from matplotlib.patches import Circle, Wedge, Polygon import numpy as np fig = plt.figure() ax = fig.add_subplot(111) labels = 'Twice Daily', 'Daily', '3-4 times per week', 'Once per week','Occasionally' fracs = [20,50,10,10,10] wedges, plt_labels = ax.pie(fracs, labels=labels) ax.axis('equal') starting_angle = 90 rotation = Affine2D().rotate(np.radians(starting_angle)) for wedge, label in zip(wedges, plt_labels): label.set_position(rotation.transform(label.get_position())) if label._x &gt; 0: label.set_horizontalalignment('left') else: label.set_horizontalalignment('right') wedge._path = wedge._path.transformed(rotation) plt.savefig("pie2") </code></pre> <p>This produces the following pie chart</p> <p><img src="https://i.stack.imgur.com/RCFwL.png" alt="enter image description here"></p> <p>However, this does not print the fracs on the wedges as in the earlier pie chart. I have tried a few different things, but I am not able to preserve the fracs. How can I start the first wedge at noon and display the fracs on the wedges as well??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload