On Fri, Sep 3, 2010 at 11:04 PM, karianne <karia...@astro.uni-bonn.de> wrote:
> Hi,
>
> I am plotting several different symbols using 3 different colours. The
> colours indicate different data sets, whereas the symbols need not be
> explained. I would therefore like each label to have a different colour,
> i.e. each line in my legend should be written in a different colour
> specified. The legend is getting too long if I have to indicate what each
> symbol represents, plus it would be a repetition of the 3 data sets in
> question. How can I change the colour of the text in the legend?

Do something like

l1, = plot([1,2,3])
leg = legend([l1], ["Test"])

leg_texts = leg.get_texts() # list of matplotlib Text instances.
leg_texts[0].set_color("b")


>
> Second, how can I change the marker in the legend? I am plotting using
> errorbar(), but the marker shows up as a dot, and I would like it to show up
> as a '+', without having to change the actual dots in the plot.

I think it is best to use a proxy artist.

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

For example,


col, leg = "b", "test"
errorbar([1,2,3], [1,2,1],xerr=[0.1, 0.1, 0.1], yerr=[0.1, 0.1, 0.1],
         fmt='.',color=col)
l2, = plot([],[], "+", color=col)
l2.remove() # remove from the axes

legend([l2], [leg])


IHTH,

-JJ

ps. A code snippet, that cannot be run standalone, is not very useful.
If you do not want to post your own data, use some fake data.

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to