> From: John Hunter <[email protected]>
> Date: October 28, 2011 5:54:36 AM PDT
> To: Adam Mercer <[email protected]>
> Cc: [email protected]
> Subject: Re: [Matplotlib-users] Legend and proxy artists
> 
> 
> On Thu, Oct 27, 2011 at 8:12 AM, Adam Mercer <[email protected]> wrote:
>> value_plot = []
>> for v in value:
>>  value_plot.append(value_axes.plot_date(w[:,0], w[:,1], 'ro-', ms=4))
>> 
>> # legend
>> date_axes.legend(([morning_plot], [evening_plot], [value_plot]),
>>    ("Morning", "Evening", "Value"),
>>    numpoints=1, loc=0, borderpad=1, shadow=True, fancybox=True)
>> 
>> # save plot
>> fig.savefig(plot_file)
> 
> Your problem is that value_plot is a list of lists, and not a list of
> lines.  ax.plot_date returns a list of lines, so you need to do
> 
> value_plot.extend(value_axes.plot_date(w[:,0], w[:,1], 'ro-', ms=4))

This by itself does not solve the problem.  The call to legend needs a list of 
handles (artists) and a list of labels.  If using the line JDH suggested, try

date_axes.legend((morning_plot[0], evening_plot[0], value_plot[0]),
   ("Morning", "Evening", "Value"),
   numpoints=1, loc=0, borderpad=1, shadow=True, fancybox=True)

With the code as it is try

date_axes.legend((morning_plot[0], evening_plot[0], value_plot[0][0]),
   ("Morning", "Evening", "Value"),
   numpoints=1, loc=0, borderpad=1, shadow=True, fancybox=True)

If neither works, then you might need to provide more information.

-Sterling
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to