[Matplotlib-users] Looking for additional help about moving a legend

2012-04-12 Thread Jonathan Bruck
Hi all,

Forgive me as this is the first time I've posted here. I've asked a
question on StackOverFlow:

http://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box#comment12952803_10101700

The question relates to adjusting the size of the figure box to accommodate
a large legend when the legend is placed below instead of on top of the
axes.

I thought I'd post here to see if there are any other answers to avoiding
having the figure box cut off the bottom of the legend.

Thanks

Jonathan
-- 
There are no passengers on Spaceship Earth.  We are all crew.

E: jdt.br...@gmail.com
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Looking for additional help about moving a legend

2012-04-12 Thread Benjamin Root
On Thu, Apr 12, 2012 at 2:05 AM, Jonathan Bruck jdt.br...@gmail.com wrote:

 Hi all,

 Forgive me as this is the first time I've posted here. I've asked a
 question on StackOverFlow:


 http://stackoverflow.com/questions/10101700/moving-matplotlib-legend-outside-of-the-axis-makes-it-cutoff-by-the-figure-box#comment12952803_10101700

 The question relates to adjusting the size of the figure box to
 accommodate a large legend when the legend is placed below instead of on
 top of the axes.

 I thought I'd post here to see if there are any other answers to avoiding
 having the figure box cut off the bottom of the legend.

 Thanks

 Jonathan
 --
 There are no passengers on Spaceship Earth.  We are all crew.

 E: jdt.br...@gmail.com


If you only care about saving the figure, the savefig() method can take
bbox='tight' and bbox_extra_artists=[legnd_obj] arguments (assuming you
save the legend to such a variable.  As for on-screen displays, I have yet
to find a solution.

Ben Root
--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to maintain fractional minor tick spacing

2012-04-12 Thread Benjamin Root
On Thu, Mar 29, 2012 at 5:53 AM, Christopher Graves 
christoph.gra...@gmail.com wrote:



 On Tue, Mar 27, 2012 at 3:31 AM, Mike Kaufman mck...@gmail.com wrote:

 On 3/26/12 12:49 PM, Christopher Graves wrote:

 On Sun, Mar 11, 2012 at 2:32 PM, Christopher Graves
 christoph.gra...@gmail.com mailto:christoph.gra...@gmail.com wrote:


 Try this:

from pylab import *
from matplotlib.ticker import AutoMinorLocator

clf()
ax=subplot(111)
ax.autoscale(tight=True)
plot([1,2,4],[1,2,3])
ax.xaxis.set_minor_locator(__AutoMinorLocator(2))
ax.yaxis.set_minor_locator(__AutoMinorLocator(2))

draw()

M

PS: I believe this is a fairly new feature...


Thanks! Great news that AutoMinorLocator has been added and
accomplishes this. Regarding the P.S. I can confirm that the feature
was not in matplotlib 1.0.1 - I had to update to 1.1.0 to use it.

Best /Chris



 Hi Mike,

 A follow-up question... When using that, if one then tries to manually
 use the zoom-box tool available with a matplotlib plot, if one draws too
 small of a box (less than 2 major ticks in x or y dimension, based on
 the following error message), it gives the following error and further
 operations on the plot do not work.

 ValueError: Need at least two major ticks to find minor tick locations
 ( File /usr/lib/pymodules/python2.7/matplotlib/ticker.py, line 1528,
 in __call__ )

 Any way to avoid this for now? (And ultimately, should this be made into
 a bug fix request?)



 Ok, I seem to remember seeing this error before, but I can't trip it now
 (with either 1.1.1rc or today's git checkout of 1.2.x). Do you have
 a short script that can reproduce this? For me, the zoom-box tool seems
 to be [correctly] setting the majortick locations as I zoom in, thus
 preventing this exception. I should note that I'm using the GTKAgg
 frontend. This may be the issue. A long time ago I was using the MacOSX
 frontend, and maybe this was when I was seeing it...

 Aside from that, this would be a bug.

 M



 On Wed, Mar 28, 2012 at 10:50 PM, Christopher Graves 
 christoph.gra...@gmail.com wrote:

 Hi Mike,

 Ok I found the root cause. Here is a short script:


 from pylab import *

 from matplotlib.ticker import MultipleLocator, AutoMinorLocator

 plot([0,3],[0,2.2])

 ax = gca()

 ax.xaxis.set_major_locator(MultipleLocator(0.5))

 ax.xaxis.set_minor_locator(AutoMinorLocator(2))

 show()


 Once MultipleLocator has been called, the auto-reassigning of tick
 spacing when zooming (either with the zoom box or the cross and right-click
 drag) does not happen, and then AutoMinorLocator has the error because it
 has majorstep = majorlocs[1] - majorlocs[0] and majorlocs has less than 2
 elements when zoomed in that far. (GTKAgg vs others doesn't matter.)

 Seems like a bug. Is it the same in the newer mpl version you have?
 For my purposes, a different fix could work, because my reason to use
 MultipleLocator is only to make x and y major ticks have equal spacing, as
 follows:

 from pylab import *

 from matplotlib.ticker import MultipleLocator, AutoMinorLocator

 ax = subplot(111, aspect='equal')

 plot([0,3],[0,1.1])

 # Set the ticks to have the same interval on both x and y axes:

 x_major_tick_interval =
 abs(ax.xaxis.get_ticklocs()[0]-ax.xaxis.get_ticklocs()[1])

 ax.yaxis.set_major_locator(MultipleLocator(x_major_tick_interval))

 # 2 minor ticks per major tick:

 ax.yaxis.set_minor_locator(AutoMinorLocator(2))

 ax.xaxis.set_minor_locator(AutoMinorLocator(2))

 show()


 aspect='equal' is not necessary to bring out the error, it just
 illustrates the purpose of this. Is there another way to fix the x and y
 tick interval as equal? (And ideally even maintain the equal spacing when
 zooming.. As it is, they initially show as equal, but when zooming they can
 lose equal visible spacing while maintaining equal value intervals.)


 Best,

 Chris



 On Thu, Mar 29, 2012 at 4:06 AM, Mike Kaufman mck...@gmail.com wrote:

 I can confirm this bug on yesterday's checkout. About equal spacing, I
 don't know offhand. A question to ask the list I think. If you could,
 please file as an issue on the github tracker. Include your code nugget
 that reproduces. Thanks.

 I don't have a lot of time at this moment, so hopefully somebody else
 looks at fixing it first.

 M



 Ok, bug is filed at https://github.com/matplotlib/matplotlib/issues/807
 I did not realize that our last couple of messages were not sent to the
 mailing-list.

 To others on mailing-list:
 Apart from someone hopefully fixing this bug, does anyone know another way
 to fix the x and y tick interval as equal, besides the way I did it in the
 last code block above, which uses
 ax.yaxis.set_major_locator(MultipleLocator(x_major_tick_interval)) after
 plotting?
 (And ideally even maintain the equal spacing when zooming.. As it is, they
 initially show as equal, but when zooming they can lose equal visible
 

Re: [Matplotlib-users] dates for x-axis

2012-04-12 Thread Goyo
El día 12 de abril de 2012 03:46, questions anon
questions.a...@gmail.com escribió:

 I am not sure how to recognise that x-axis are dates like 20110101,
 20110102, 20110103 etc.

Use datetime objects instead of strings.

Goyo

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] how to maintain fractional minor tick spacing

2012-04-12 Thread Christopher Graves
On Thu, Apr 12, 2012 at 5:20 PM, Benjamin Root ben.r...@ou.edu wrote:



 On Thu, Mar 29, 2012 at 5:53 AM, Christopher Graves 
 christoph.gra...@gmail.com wrote:



 On Tue, Mar 27, 2012 at 3:31 AM, Mike Kaufman mck...@gmail.com wrote:

 On 3/26/12 12:49 PM, Christopher Graves wrote:

 On Sun, Mar 11, 2012 at 2:32 PM, Christopher Graves
 christoph.gra...@gmail.com mailto:christoph.gra...@gmail.com wrote:


 Try this:

from pylab import *
from matplotlib.ticker import AutoMinorLocator

clf()
ax=subplot(111)
ax.autoscale(tight=True)
plot([1,2,4],[1,2,3])
ax.xaxis.set_minor_locator(__AutoMinorLocator(2))
ax.yaxis.set_minor_locator(__AutoMinorLocator(2))

draw()

M

PS: I believe this is a fairly new feature...


Thanks! Great news that AutoMinorLocator has been added and
accomplishes this. Regarding the P.S. I can confirm that the feature
was not in matplotlib 1.0.1 - I had to update to 1.1.0 to use it.

Best /Chris



 Hi Mike,

 A follow-up question... When using that, if one then tries to manually
 use the zoom-box tool available with a matplotlib plot, if one draws too
 small of a box (less than 2 major ticks in x or y dimension, based on
 the following error message), it gives the following error and further
 operations on the plot do not work.

 ValueError: Need at least two major ticks to find minor tick locations
 ( File /usr/lib/pymodules/python2.7/matplotlib/ticker.py, line 1528,
 in __call__ )

 Any way to avoid this for now? (And ultimately, should this be made into
 a bug fix request?)



 Ok, I seem to remember seeing this error before, but I can't trip it now
 (with either 1.1.1rc or today's git checkout of 1.2.x). Do you have
 a short script that can reproduce this? For me, the zoom-box tool seems
 to be [correctly] setting the majortick locations as I zoom in, thus
 preventing this exception. I should note that I'm using the GTKAgg
 frontend. This may be the issue. A long time ago I was using the MacOSX
 frontend, and maybe this was when I was seeing it...

 Aside from that, this would be a bug.

 M



 On Wed, Mar 28, 2012 at 10:50 PM, Christopher Graves 
 christoph.gra...@gmail.com wrote:

 Hi Mike,

 Ok I found the root cause. Here is a short script:


 from pylab import *

 from matplotlib.ticker import MultipleLocator, AutoMinorLocator

 plot([0,3],[0,2.2])

 ax = gca()

 ax.xaxis.set_major_locator(MultipleLocator(0.5))

 ax.xaxis.set_minor_locator(AutoMinorLocator(2))

 show()


 Once MultipleLocator has been called, the auto-reassigning of tick
 spacing when zooming (either with the zoom box or the cross and right-click
 drag) does not happen, and then AutoMinorLocator has the error because it
 has majorstep = majorlocs[1] - majorlocs[0] and majorlocs has less than 2
 elements when zoomed in that far. (GTKAgg vs others doesn't matter.)

 Seems like a bug. Is it the same in the newer mpl version you have?
 For my purposes, a different fix could work, because my reason to use
 MultipleLocator is only to make x and y major ticks have equal spacing, as
 follows:

 from pylab import *

 from matplotlib.ticker import MultipleLocator, AutoMinorLocator

 ax = subplot(111, aspect='equal')

 plot([0,3],[0,1.1])

 # Set the ticks to have the same interval on both x and y axes:

 x_major_tick_interval =
 abs(ax.xaxis.get_ticklocs()[0]-ax.xaxis.get_ticklocs()[1])

 ax.yaxis.set_major_locator(MultipleLocator(x_major_tick_interval))

 # 2 minor ticks per major tick:

 ax.yaxis.set_minor_locator(AutoMinorLocator(2))

 ax.xaxis.set_minor_locator(AutoMinorLocator(2))

 show()


 aspect='equal' is not necessary to bring out the error, it just
 illustrates the purpose of this. Is there another way to fix the x and y
 tick interval as equal? (And ideally even maintain the equal spacing when
 zooming.. As it is, they initially show as equal, but when zooming they can
 lose equal visible spacing while maintaining equal value intervals.)


 Best,

 Chris



 On Thu, Mar 29, 2012 at 4:06 AM, Mike Kaufman mck...@gmail.com wrote:

 I can confirm this bug on yesterday's checkout. About equal spacing, I
 don't know offhand. A question to ask the list I think. If you could,
 please file as an issue on the github tracker. Include your code nugget
 that reproduces. Thanks.

 I don't have a lot of time at this moment, so hopefully somebody else
 looks at fixing it first.

 M



 Ok, bug is filed at https://github.com/matplotlib/matplotlib/issues/807
 I did not realize that our last couple of messages were not sent to the
 mailing-list.

 To others on mailing-list:
 Apart from someone hopefully fixing this bug, does anyone know another
 way to fix the x and y tick interval as equal, besides the way I did it in
 the last code block above, which uses
 ax.yaxis.set_major_locator(MultipleLocator(x_major_tick_interval)) after
 plotting?
 (And ideally even maintain the equal spacing when zooming.. As it is,
 they 

Re: [Matplotlib-users] Focus in OSX

2012-04-12 Thread Michiel de Hoon
--- On Wed, 4/11/12, Zachary Pincus zachary.pin...@yale.edu wrote:
 Hopefully someone who knows more about the OS X backend can
 comment here...

It sounds like the Python you are using is not installed as a framework. Using 
the --enable-framework flag when compiling Python.

-Michiel.

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users