Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ordinarily I wouldn't recommend changing the source of a tool, but it's hacky to fix this outside and easy inside. So here's what I'd do if you needed this to work Right Now(tm), and sometimes you do..</p> <p>In the file <code>matplotlib/axes.py</code>, change the declaration of the pie function to</p> <pre><code>def pie(self, x, explode=None, labels=None, colors=None, autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1, start_angle=None): </code></pre> <p>i.e. simply add <code>start_angle=None</code> to the end of the arguments.</p> <p>Then add the five lines bracketed by "# addition".</p> <pre><code> for frac, label, expl in cbook.safezip(x,labels, explode): x, y = center theta2 = theta1 + frac thetam = 2*math.pi*0.5*(theta1+theta2) # addition begins here if start_angle is not None and i == 0: dtheta = (thetam - start_angle)/(2*math.pi) theta1 -= dtheta theta2 -= dtheta thetam = start_angle # addition ends here x += expl*math.cos(thetam) y += expl*math.sin(thetam) </code></pre> <p>Then if start_angle is None, nothing happens, but if start_angle has a value, then that's the location that the first slice (in this case the 20%) is centred on. For example,</p> <pre><code>patches, texts, autotexts = ax.pie(fracs, labels=labels, explode = explode, autopct='%1.1f%%', shadow =True, start_angle=0.75*pi) </code></pre> <p>produces</p> <p><img src="https://i.stack.imgur.com/YMU1I.png" alt="enter image description here"></p> <p>Note that in general you should avoid doing this, patching the source I mean, but there are times in the past when I've been on deadline and simply wanted something Now(tm), so there you go..</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      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