From: meow on

As a beginner in python and matplotlib I come here with a possibly
naïve question. I need to write code for automation of bar-plots and
pie-charts creation. I chose to use matplotlib which is well adapted
for this purpose. Nevertheless, some of my charts are not very legible
due to interferences between to many or to long labels.

Sometimes my labels spread over the edge of the picture, and therefore
are simply cut out; sometimes the different labels superpose,
resulting in an illegible pie-chart.

Do you know an easy way to control the labels size and repartition ?
Is it possible to prohibit the label cutting, for instance a way to
set the picture size so that no label is cut anymore ?
Does matplotlib provide an easy way to spread labels or pie chunks so
that the labels do not interfere with each other ?

You will find my two code samples here after

Any hint or recommendation appreciated

# pie chart code
def savePie(populationGO,filepath,figtitle):
""" saves Pie Charts of a population to a file """
labels=[k+"\n"+str(v) for k,v in populationGO.iteritems()]

# bar plot code
barPlotOffsets = np.arange(len(labels))
r1 = ,popGO ,color="r",width=barPlotWidth)
r2 =
+barPlotWidth ,popGOall ,color="g",width=barPlotWidth)
r3 =
+(2*barPlotWidth) ,popGOlowr ,color="b",width=barPlotWidth)
plt.ylabel('Population (number of protein chains)')
plt.title('GO Population by simplified GO and dataset')
plt.xticks(barPlotOffsets+barPlotWidth, labels,rotation = 17 )
plt.legend( (r1[0],r2[0],r3[0]), ("all SIFTS annotated","all PDB
protein chains","all PDB p.chains R<=2.1") )
print "\nSave comparative bar plot file"
fileName = "GO-population--comparative-bar-plot.png"
print "...",fileName
Pages: 1
Prev: expat parsing error
Next: Drawing Multigraphs