[matplotlib-devel] xlim() turns off autoscaling

2011-02-06 Thread Mike Kaufman

The help for xlim() says:

 Set/Get the xlimits of the current axes::

   xmin, xmax = xlim()   # return the current xlim
   xlim( (xmin, xmax) )  # set the xlim to xmin, xmax
   xlim( xmin, xmax )# set the xlim to xmin, xmax


but it also has the unexpected behavior of turning off autoscaling if used:

-
import matplotlib.pyplot as plt

plt.clf()
ax = plt.subplot(211)
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',plt.xlim()
ax.plot([0,.5,1,1.5,2],[0,1,0,1,0])
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'

ax = plt.subplot(212)
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim()
plt.plot([0,.5,1,1.5,2],[0,1,0,1,0])
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
-

returns:

 >>> import xlim_unautoscale
autoscale X on:  True  xlim:  (0.0, 1.0)
autoscale X on:  False  xlim:  (0.0, 1.0)

autoscale X on:  True  xlim:  (0.0, 1.0)
autoscale X on:  True  xlim:  (0.0, 2.0)


I assume that this is because xlim() calls set_xlim() which has 
auto=False as a default keyword...

expected behavior: xlim() should behave exactly like get_xlim()
ditto for ylim()

M

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] xlim() turns off autoscaling

2011-02-06 Thread Eric Firing
On 02/06/2011 06:59 AM, Mike Kaufman wrote:
>
> The help for xlim() says:
>
>   Set/Get the xlimits of the current axes::
>
> xmin, xmax = xlim()   # return the current xlim
> xlim( (xmin, xmax) )  # set the xlim to xmin, xmax
> xlim( xmin, xmax )# set the xlim to xmin, xmax
>
>
> but it also has the unexpected behavior of turning off autoscaling if used:
>
> -
> import matplotlib.pyplot as plt
>
> plt.clf()
> ax = plt.subplot(211)
> plt.draw()
> print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',plt.xlim()
> ax.plot([0,.5,1,1.5,2],[0,1,0,1,0])
> plt.draw()
> print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
>
> ax = plt.subplot(212)
> plt.draw()
> print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim()
> plt.plot([0,.5,1,1.5,2],[0,1,0,1,0])
> plt.draw()
> print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
> -
>
> returns:
>
>   >>>  import xlim_unautoscale
> autoscale X on:  True  xlim:  (0.0, 1.0)
> autoscale X on:  False  xlim:  (0.0, 1.0)
>
> autoscale X on:  True  xlim:  (0.0, 1.0)
> autoscale X on:  True  xlim:  (0.0, 2.0)
>
>
> I assume that this is because xlim() calls set_xlim() which has
> auto=False as a default keyword...
>
> expected behavior: xlim() should behave exactly like get_xlim()
> ditto for ylim()

I agree, so I have fixed this in the maintenance branch and in the trunk.

Eric

>
> M
>
> --
> The modern datacenter depends on network connectivity to access resources
> and provide services. The best practices for maximizing a physical server's
> connectivity to a physical network are well understood - see how these
> rules translate into the virtual world?
> http://p.sf.net/sfu/oracle-sfdevnlfb
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] xlim() turns off autoscaling

2011-02-06 Thread Benjamin Root
On Sun, Feb 6, 2011 at 11:52 AM, Eric Firing  wrote:

> On 02/06/2011 06:59 AM, Mike Kaufman wrote:
> >
> > The help for xlim() says:
> >
> >   Set/Get the xlimits of the current axes::
> >
> > xmin, xmax = xlim()   # return the current xlim
> > xlim( (xmin, xmax) )  # set the xlim to xmin, xmax
> > xlim( xmin, xmax )# set the xlim to xmin, xmax
> >
> >
> > but it also has the unexpected behavior of turning off autoscaling if
> used:
> >
> > -
> > import matplotlib.pyplot as plt
> >
> > plt.clf()
> > ax = plt.subplot(211)
> > plt.draw()
> > print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',plt.xlim()
> > ax.plot([0,.5,1,1.5,2],[0,1,0,1,0])
> > plt.draw()
> > print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
> >
> > ax = plt.subplot(212)
> > plt.draw()
> > print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim()
> > plt.plot([0,.5,1,1.5,2],[0,1,0,1,0])
> > plt.draw()
> > print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
> > -
> >
> > returns:
> >
> >   >>>  import xlim_unautoscale
> > autoscale X on:  True  xlim:  (0.0, 1.0)
> > autoscale X on:  False  xlim:  (0.0, 1.0)
> >
> > autoscale X on:  True  xlim:  (0.0, 1.0)
> > autoscale X on:  True  xlim:  (0.0, 2.0)
> >
> >
> > I assume that this is because xlim() calls set_xlim() which has
> > auto=False as a default keyword...
> >
> > expected behavior: xlim() should behave exactly like get_xlim()
> > ditto for ylim()
>
> I agree, so I have fixed this in the maintenance branch and in the trunk.
>
> Eric
>
>
Something I just noticed while looking at the x|ylim() functions.  The code
for xscale() and yscale() are acting like it returns something, but they
don't.  Is this a bug?  The documentation doesn't claim that it returns
anything.

Ben Root
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] xlim() turns off autoscaling

2011-02-06 Thread Eric Firing
On 02/06/2011 08:11 AM, Benjamin Root wrote:
[...]
>
> Something I just noticed while looking at the x|ylim() functions.  The
> code for xscale() and yscale() are acting like it returns something, but
> they don't.  Is this a bug?  The documentation doesn't claim that it
> returns anything.

Ben,

Like ax.xscale etc, it returns None.

It's not exactly a bug--the behavior is correct and matches the 
documentation--but the code is misleading and less concise than it could 
be.  Having noticed it, you might as well clean it up.  The code would 
be clearer without the use of "ret" and "return", though the end effect 
will be no different.

Eric


>
> Ben Root
>

--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Legend style with axes.hist(histtype='step')

2011-02-06 Thread Nicholas Devenish
One of the things that bugs me about axes.hist is that with
histtype='step' the automatic legend style is an empty box, instead of
a line, as I would expect. This behaviour doesn't seem to make sense,
because it seems a line would be much more appropriate for this case.
Example is attached for the code:

import matplotlib.pyplot as plt
plt.hist([0,1,1,2,2,2], [0,1,2,3], histtype='step', label="histtype='step'")
plt.legend()
plt.show()

I can get around this by using proxy Line2D objects in building the
legend, but as this is an extremely common operation for me (the
common style of histograms in my field is equivalent to step) this
becomes messy and annoying. I'd rather not have to roll my own
histogram drawing function, as it would be almost entirely duplicating
the axes hist code, and don't know another way to get what I want. I
understand that the way of setting Legend styles is something that has
been looked at recently, but don't know the timescale for any changes.

The cause of this is the fact that in axes.py::7799 (current SVN
head), in axes.hist, patch objects are always created, even for the
line-based step style. I searched the tracker briefly, and couldn't
find this mentioned before. I therefore have a few questions:

- Is this intended behaviour, that I am just not understanding the
requirement for?
- Would changing this to create (and thus return) Line2D's instead of
Patch's for this histtype be a horrible breaking of the return
interface?

I've attached a patch that makes the simple change of swapping out the
call to .fill for .plot (only the function is changed here, not yet
the documentation), and it appears to work but I haven't tested
exhaustively.

Thoughts?

Nick
<>

histtype_plot.patch
Description: Binary data
--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel