Hi all,
I am trying to create legend with multiple-line labels, but I noticed that the labels are not properly aligned. I tried also changing the alignment of the text objects to center, but this requires separate handling of multi-line and single-line labels:
import matplotlib.pyplot as plt
plt.plot([1,2,3], label"multi\nline 1")
plt.plot([1,2,3], label="multi\nline 1")
plt.plot([1,2,3], label="multi\nline 2")
plt.plot([1,2,3], label=" single line")
leg=plt.legend()
#change alignment of multiline labels only
plt.setp(leg.get_texts()[:2], va='center')
I found a discussion thread on this topic:
http://article.gmane.org/gmane.comp.python.matplotlib.devel/6116
Is there a way to achieve a clean rendering independent of number of lines?
Yours,
Bartosz
I presume that you're using matploltib v1.0?
It seems that the bug was recently introduced as the baseline of the
multiline text has been recently changed.
This should be fixed this in r8564, and r8565.
Unfortunately, I don't see any easy workaround other than changing the
vertical alignment of multiline text as you suggested (but the code
will produce erroneous baseline with the fixed matplotlib).
Regards,
-JJ
ยทยทยท
On Fri, Jul 16, 2010 at 9:17 AM, Bartosz Telenczuk <b.telenczuk@...2786...> wrote:
Hi all,
I am trying to create legend with multiple-line labels, but I noticed that the labels are not properly aligned. I tried also changing the alignment of the text objects to center, but this requires separate handling of multi-line and single-line labels:
import matplotlib.pyplot as plt
plt.plot([1,2,3], label"multi\nline 1")
plt.plot([1,2,3], label="multi\nline 1")
plt.plot([1,2,3], label="multi\nline 2")
plt.plot([1,2,3], label=" single line")
leg=plt.legend()
#change alignment of multiline labels only
plt.setp(leg.get_texts()[:2], va='center')
I found a discussion thread on this topic:
http://article.gmane.org/gmane.comp.python.matplotlib.devel/6116
Is there a way to achieve a clean rendering independent of number of lines?
Yours,
Bartosz
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options