How to avoid overlapping of labels & autopct in a pie chart

Alternatively you can put the legends beside the pie graph: import matplotlib.pyplot as plt import numpy as np x = np.char.array([‘Jan’,’Feb’,’Mar’,’Apr’,’May’,’Jun’,’Jul’,’Aug’,’Sep’,’Oct’, ‘Nov’,’Dec’]) y = np.array([234, 64, 54,10, 0, 1, 0, 9, 2, 1, 7, 7]) colors = [‘yellowgreen’,’red’,’gold’,’lightskyblue’,’white’,’lightcoral’,’blue’,’pink’, ‘darkgreen’,’yellow’,’grey’,’violet’,’magenta’,’cyan’] porcent = 100.*y/y.sum() patches, texts = plt.pie(y, colors=colors, startangle=90, radius=1.2) labels = [‘{0} – {1:1.2f} %’.format(i,j) … Read more

Label outside arc (Pie chart) d3.js

I can solve that problem – with trigonometry :). See fiddle: http://jsfiddle.net/nrabinowitz/GQDUS/ Basically, calling arc.centroid(d) returns an [x,y] array. You can use the Pythagorean Theorem to calculate the hypotenuse, which is the length of the line from the center of the pie to the arc centroid. Then you can use the calculations x/h * desiredLabelRadius … Read more

How to set the labels size on a pie chart in python

The simplest way to change the font size on a pie chart is directly via the textprops argument in the pie() function. Using the code above add it like so: ax.pie(frac, colors=colors ,labels=labels, autopct=”%1.1f%%”, textprops={‘fontsize’: 14}) That way you can just pass in a dictionary with your desired fontsize (e.g., 14). No messing around with … Read more

How do I use matplotlib autopct?

autopct enables you to display the percent value using Python string formatting. For example, if autopct=”%.2f”, then for each pie wedge, the format string is ‘%.2f’ and the numerical percent value for that wedge is pct, so the wedge label is set to the string ‘%.2f’%pct. import matplotlib.pyplot as plt plt.figure() values = [3, 12, … Read more