On Thu, Jul 16, 2009 at 10:49 PM, per freem<perfr...@gmail.com> wrote:
> hi all,
>
> suppose i have am plotting several lines using 'plot', some are dashed
> (using '--') and some are ordinary solid lines. i am plotting several solid
> and several dashed lines, all in different colors, as in:
>
> for n in num_lines:
>   # plot dashed line
>   plot(line_x[n], line_y[n], '--', color=line_color[n], label="line %d"
> %(n))
>   # plot ordinary line in different color
>   plot(line_x[n], line_y[n], color=other_line_color[n], label="line %d"
> %(n))
>   ...
>
> If i plot n lines, i don't want the legend to show n-items, giving a
> separate key for each line. rather, i want it to display a legend containing
> a label for the dashed lines and a label for the solid lines, as in:
>
> Legend:
> [-- line of type A
>  -  line of type B]
>
> so 2 entries rather than as many entries as i have lines. how can i do this?
>

If you set "_nolegend_" as label, that line will not be displayed in the legend.

http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=legend#matplotlib.pyplot.legend

Or, you may manually select which lines to be displayed.
See the above documentation for more details.


> finally, how can i make it so the legend does not interfere with the plot?
> right now the lines appear "behind" the legend. it'd be great if the legend
> could be made to be in the background of the line (i.e. be transparent.)
>

reduce the zorder of the legend less than that of the lines.

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=zorder#matplotlib.artist.Artist.set_zorder

e.g.,

l = legend()
l.set_zorder(0)


Regards,

-JJ


> thank you.
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to