From: Benoit H. <ben...@ga...> - 2008-06-11 18:38:22
|
Hello, Pie charts are very useful, but when wedges labels are too long, the label text overlaps the pie wedge, resulting in a poor readability (see the attached file 'before_patch.pdf'). I propose to modify the file 'axes.py' in method 'pie' by replacing: xt = x + labeldistance*radius*math.cos(thetam) yt = y + labeldistance*radius*math.sin(thetam) t = self.text(xt, yt, label, size=rcParams['xtick.labelsize'], horizontalalignment='center', verticalalignment='center') texts.append(t) By: xt = x + labeldistance*radius*math.cos(thetam) yt = y + labeldistance*radius*math.sin(thetam) label_alignment = xt > 0 and 'left' or 'right' t = self.text(xt, yt, label, size=rcParams['xtick.labelsize'], horizontalalignment=label_alignment, verticalalignment='center') texts.append(t) Only 2 lines changed ;-) This way, labels are right aligned when placed at the left of the pie, and left aligned when placed on the right of the pie (instead of being always centered). See the attached file 'after_patch.pdf' for an example. I also give an example in the example.py file. Do you agree to commit that to the trunk? Thanks for making matplotlib, Benoit Hirbec Garden |