From: John Hunter <jdh2358@...287...>
Date: October 28, 2011 5:54:36 AM PDT
To: Adam Mercer <ramercer@...287...>
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] Legend and proxy artistsvalue_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 dovalue_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
···
On Thu, Oct 27, 2011 at 8:12 AM, Adam Mercer <ramercer@...287...> wrote: