Or, you may fool the algorithm to find the best location by adding
invisible lines.
For example,

axessubplot4.set_autoscale_on(False)
l1, = axessubplot4.plot([4, 5], [8, 18])
l1.set_visible(False)
axessubplot4.set_autoscale_on(True)

Regards,

-JJ


On Thu, Feb 11, 2010 at 10:58 AM, John Hunter <jdh2...@gmail.com> wrote:
> On Thu, Feb 11, 2010 at 9:43 AM, Geoff Bache <geoff.ba...@jeppesen.com> wrote:
>>
>> Hi all,
>>
>> I'm trying to generate graphs from my test results, with regions
>> coloured with succeeded and failing tests. It nearly works, but I have
>> the following problem. I am providing the data with fill_between, which
>> returns PolyCollection objects which cannot be provided to a legend. So
>> I use the "proxy artist" trick, as described here
>>
>> http://matplotlib.sourceforge.net/users/legend_guide.html#plotting-guide-legend
>>
>
> What about creating a proxy artist which is a simple polygon that has
> the same outline as your fill_between polygon?
>
>
> In [539]: t = np.arange(0, 1, 0.05)
>
> In [540]: y = np.sin(2*np.pi*t)
>
> In [541]: verts = zip(t, y)
>
> In [542]: proxy = mpatches.Polygon(verts, facecolor='yellow')
>
> The only reason fill_between uses a PolyCollection is to support the
> "where" keyword argument for non-contiguous fill regions, which you do
> not appear to be using.  Thus you could simply create the polygon
> yourself with a little calculation (see mlab.poly_between for a helper
> function) and then just add that patch to the axes rather than using
> fill_between::
>
>  t = np.arange(0, 1, 0.05)
>  ymin = np.sin(2*np.pi*t)-5
>  ymax = np.sin(2*np.pi*t)+5
>  xs, ys = mlab.poly_between(t, ymin, ymax)
>  verts = zip(xs, ys)
>  poly = mpatches.Polygon (verts, facecolor='red', label='my poly')
>  ax = subplot(111)
>  ax.add_patch(poly)
>  ax.legend(loc='best')
>  ax.axis([0, 1, -6, 6])
>  plt.draw()
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to