Re: [matplotlib-devel] Completely wrong tick formatting

2013-07-08 Thread Pål Gunnar Ellingsen
Hi

Thank you that solves the problem we had.
I'm sorry for posting this on the development list, it was intended for the
users list, and I somehow entered the wrong address.

Regards

Pål

On 7 July 2013 21:44, Eric Firing  wrote:

> On 2013/07/04 11:43 PM, Pål Gunnar Ellingsen wrote:
> > Hi
> >
> > I'm having some problems with the formatter of ticks in a polar plot.
> > Below is a minimum example
> > The first figure is correct, the second has wrong ticks.
> >
> > This has be tested both on 1.2.0 and the latest from git (1.4.x, commit
> > 64cc3416396ffb2811af80fc810ed63572df71d9 )
> >
> > Does anyone know whys this happens?
> > Is it a bug in MaxNLocator
>
> No, it is a misunderstanding of how the colorbar works.  It's long axis
> is using its own units, and it maps the color scale to those units.
> Therefore, one should not try to manipulate the axis properties
> directly.  Below I show two altered lines and one deletion.  I think
> this will produce what you want.
>
> >
> > Kind regards
> >
> > Pål
> >
> > ---
> > #!/usr/bin/env python
> >
> > import numpy as np
> > import matplotlib.pyplot as plt
> > from matplotlib.ticker import MaxNLocator
> >
> > # Data
> > M=np.sin(np.meshgrid(np.arange(30),np.arange(30)))
> > M=np.squeeze(M[0,:,:])
> > Radius=np.arange(30)
> > Theta=np.arange(30)
> >
> > # Plotting the correct figure
> > print('Correct ticks')
> > fig=plt.figure()
> > ax1 = fig.add_axes([0,0,0.8,1],projection='polar')
> > c = ax1.pcolormesh(Theta, Radius, M)
> > ax1.set_frame_on(False)
> > plt.xticks([])
> > plt.yticks([])
> > ax2=fig.add_axes([0.9,0.1,0.05,0.7])
> > cb=fig.colorbar(c,cax=ax2)
> > plt.show()
> >
> > # Doing the same plot
> > print('Wrong ticks by using formatter')
> > fig=plt.figure()
> > ax1 = fig.add_axes([0,0,0.8,1],projection='polar')
> #> c = ax1.pcolormesh(Theta, Radius, M)
>
> c = ax1.pcolormesh(Theta, Radius, M, vmin=-1, vmax=1)
>
> > ax1.set_frame_on(False)
> > plt.xticks([])
> > plt.yticks([])
> > ax2=fig.add_axes([0.9,0.1,0.05,0.7])
> #> cb=fig.colorbar(c,cax=ax2)
>
> cb = fig.colorbar(c, cax=ax2, ticks=MaxNLocator(3))
>
> >
> #> # except now setting a limit to the number of ticks using a formatter
> #> # which results in wrong ticks
> #> cb.ax.yaxis.set_major_locator(MaxNLocator(3))
>
> > plt.show()
>
> Eric
>
> > ---
> >
> >
> >
> --
> > This SF.net email is sponsored by Windows:
> >
> > Build for Windows Store.
> >
> > http://p.sf.net/sfu/windows-dev2dev
> >
> >
> >
> > ___
> > Matplotlib-devel mailing list
> > Matplotlib-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> >
>
>
>
> --
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Reorganizing axes plot methods

2013-07-08 Thread Tony Yu
This is an idea that's been kicking around in my head for awhile.
Basically, the Axes class is way too expansive. Nelle made a major step in
the right direction with a PR that split it up into plotting and
non-plotting methods:

https://github.com/matplotlib/matplotlib/pull/1931/files

What I'd like to see is something that further separates plotting methods
into many smaller sub-modules/-packages. Organizing the code this way would
make it easier (for me at least) to read, understand, and make changes to
the code.

I think that this could be done in an API-compatible way. In fact, a few of
the plotting methods are already implemented this way: In other words, the
bulk of the methods are implemented as functions outside of Axes, and the
Axes methods that are just thin wrappers around those functions (or
classes). See, for example, `streamplot`, `barbs`, and `quiver` methods

The examples mentioned above simply take the axes as the first parameter.
Here's the Axes-method definition of `quiver`, for example:

def quiver(self, *args, **kw):
...
q = mquiver.Quiver(self, *args, **kw)
...
return q

(might be a good idea to add a decorator to maintain the function signature
and docstring)

This should work for any of the plotting methods (I would imagine). Another
alternative is for all these plotting functions to have an `ax` (or some
other spelling) keyword argument that defaults to None and then have a line
in every function that does something like

ax = ax if ax is not None else plt.gca()

If I'm not mistaken, this would allow pyplot functions to be even thinner
wrappers around these newly extracted functions. (In some cases, it might
just be a simple import from the the new sub-package/-module into the
`pyplot` namespace).

I haven't sat down and thought through all the details of such a change,
but I wanted to throw it out there to see if anything sticks.

Cheers,
-Tony
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Reorganizing axes plot methods

2013-07-08 Thread Eric Firing
On 2013/07/08 7:19 PM, Tony Yu wrote:
> This is an idea that's been kicking around in my head for awhile.
> Basically, the Axes class is way too expansive. Nelle made a major step
> in the right direction with a PR that split it up into plotting and
> non-plotting methods:
>
> https://github.com/matplotlib/matplotlib/pull/1931/files
>
> What I'd like to see is something that further separates plotting
> methods into many smaller sub-modules/-packages. Organizing the code
> this way would make it easier (for me at least) to read, understand, and
> make changes to the code.
>
> I think that this could be done in an API-compatible way. In fact, a few
> of the plotting methods are already implemented this way: In other
> words, the bulk of the methods are implemented as functions outside of
> Axes, and the Axes methods that are just thin wrappers around those
> functions (or classes). See, for example, `streamplot`, `barbs`, and
> `quiver` methods

I agree.  I would like to see logical groups of plot types broken out 
into modules.

>
> The examples mentioned above simply take the axes as the first
> parameter. Here's the Axes-method definition of `quiver`, for example:
>
>  def quiver(self, *args, **kw):
>  ...
>  q = mquiver.Quiver(self, *args, **kw)
>  ...
>  return q
>
> (might be a good idea to add a decorator to maintain the function
> signature and docstring)
>
> This should work for any of the plotting methods (I would imagine).
> Another alternative is for all these plotting functions to have an `ax`
> (or some other spelling) keyword argument that defaults to None and then
> have a line in every function that does something like
>
>  ax = ax if ax is not None else plt.gca()
>
> If I'm not mistaken, this would allow pyplot functions to be even
> thinner wrappers around these newly extracted functions. (In some cases,
> it might just be a simple import from the the new sub-package/-module
> into the `pyplot` namespace).
>

This would require pyplot to be imported by everything, wouldn't it? 
That would completely defeat the strategy of having an OO level that 
doesn't know about pyplot at all, and then having pyplot be the thin top 
layer.

Eric

> I haven't sat down and thought through all the details of such a change,
> but I wanted to throw it out there to see if anything sticks.
>
> Cheers,
> -Tony
>
>
> --
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>
>
>
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>


--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Reorganizing axes plot methods

2013-07-08 Thread Nelle Varoquaux
On 9 July 2013 08:24, Eric Firing  wrote:
> On 2013/07/08 7:19 PM, Tony Yu wrote:
>> This is an idea that's been kicking around in my head for awhile.
>> Basically, the Axes class is way too expansive. Nelle made a major step
>> in the right direction with a PR that split it up into plotting and
>> non-plotting methods:
>>
>> https://github.com/matplotlib/matplotlib/pull/1931/files
>>
>> What I'd like to see is something that further separates plotting
>> methods into many smaller sub-modules/-packages. Organizing the code
>> this way would make it easier (for me at least) to read, understand, and
>> make changes to the code.
>>
>> I think that this could be done in an API-compatible way. In fact, a few
>> of the plotting methods are already implemented this way: In other
>> words, the bulk of the methods are implemented as functions outside of
>> Axes, and the Axes methods that are just thin wrappers around those
>> functions (or classes). See, for example, `streamplot`, `barbs`, and
>> `quiver` methods
>
> I agree.  I would like to see logical groups of plot types broken out
> into modules.

That's the second step in the refactoring of the axes module.
We now have to discuss how to organize plots in subtypes that make
sense. At Scipy, we discussed a bit about it, and we think it should
follow the same organization as the gallery, but I don't know whether
the gallery reorganization is logical enough right now to start the
refactoring straight away.

Should we discuss about this here, or in a ticket?

>>
>> The examples mentioned above simply take the axes as the first
>> parameter. Here's the Axes-method definition of `quiver`, for example:
>>
>>  def quiver(self, *args, **kw):
>>  ...
>>  q = mquiver.Quiver(self, *args, **kw)
>>  ...
>>  return q
>>
>> (might be a good idea to add a decorator to maintain the function
>> signature and docstring)
>>
>> This should work for any of the plotting methods (I would imagine).
>> Another alternative is for all these plotting functions to have an `ax`
>> (or some other spelling) keyword argument that defaults to None and then
>> have a line in every function that does something like
>>
>>  ax = ax if ax is not None else plt.gca()
>>
>> If I'm not mistaken, this would allow pyplot functions to be even
>> thinner wrappers around these newly extracted functions. (In some cases,
>> it might just be a simple import from the the new sub-package/-module
>> into the `pyplot` namespace).
>>
>
> This would require pyplot to be imported by everything, wouldn't it?
> That would completely defeat the strategy of having an OO level that
> doesn't know about pyplot at all, and then having pyplot be the thin top
> layer.
>
> Eric
>
>> I haven't sat down and thought through all the details of such a change,
>> but I wanted to throw it out there to see if anything sticks.
>>
>> Cheers,
>> -Tony
>>
>>
>> --
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>>
>>
>>
>> ___
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>
>
> --
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel