[Matplotlib-users] bug in fcontour with v1.1.0 ?

2011-12-05 Thread Arnaud
Hello,

I am new to this list, but not totally to matplotlib.
I installed v1.1.0 lately, and i noticed that something went wrong (or,
not as before) with fcontour(). 
It looks like the range of colors used to fill in, is not set correctly.
Sorry, i cannot really tel it better, but i have a piece of source code,
that highlights the phenomenon : 

#!/usr/bin/python
import os
import sys
from pylab import *

# parameters we bach on
x = linspace(-10,10,30)
y = linspace(-4,4,30)
X,Y = meshgrid(x,y)
F = 0.5*X**2 + (7*Y**2)/2

fig = figure(num=None, figsize=(6, 6), dpi=80, facecolor='#66',
edgecolor='k')

ax = fig.gca()

cmap=get_cmap('reds')
plage = arange(0,100,1)
surf = contourf(X,Y,F, plage)
plage = arange(0,100,2)
surf = contour(X,Y,F, plage, linewidths=2)

ax.grid(True)
fig.colorbar(surf, shrink=0.5, aspect=5)
axis([x.min(),x.max(),y.min(),y.max()])

show()


I ran it with pyV2.6/matplotlibV0.99.1, and it behaves differently with
pyV2.7/matplotlibV1.1.0 .

Could you confirm that on your computer, if this is an expected
behaviour, and, if not, if you have an idea about how to fix it ?

thanks a lot,
Arnaud.




--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bug in fcontour with v1.1.0 ?

2011-12-06 Thread Arnaud
Hello, and thank you for this answer.

I do not care that much of the colorbar, i added it to make sure the
range actually started at 0.
I used the contour function to that purpose too i.e.  to show that my
function actally ranged from 0 to 100.

Removing both colorbar and contour, i have the same result.

I finally found a solution to this : i changed the backend
in .matplotlibrc from GTK to GTKAgg, and it works.

thanks again for answering!
best
-- 
RHENOVIA - Arnaud LEGENDRE.


Le lundi 05 décembre 2011 à 20:04 -1000, Eric Firing a écrit :
> On 12/05/2011 10:00 AM, Arnaud wrote:
> > Hello,
> >
> > I am new to this list, but not totally to matplotlib.
> > I installed v1.1.0 lately, and i noticed that something went wrong (or,
> > not as before) with fcontour().
> > It looks like the range of colors used to fill in, is not set correctly.
> > Sorry, i cannot really tel it better, but i have a piece of source code,
> > that highlights the phenomenon :
> 
> Try removing the call to contour; it is not doing you any good, at least 
> in this example. You are passing its ContourSet return object to your 
> colorbar call, so your colorbar is showing the contour lines, not the 
> continuous range of colors, which I think is what you want.
> 
> You can show both contourf colors and contour lines on a colorbar, if 
> you do want that; see
> http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html
> 
> Eric
> 
> >
> > #!/usr/bin/python
> > import os
> > import sys
> > from pylab import *
> >
> > # parameters we bach on
> > x = linspace(-10,10,30)
> > y = linspace(-4,4,30)
> > X,Y = meshgrid(x,y)
> > F = 0.5*X**2 + (7*Y**2)/2
> >
> > fig = figure(num=None, figsize=(6, 6), dpi=80, facecolor='#66',
> > edgecolor='k')
> >
> > ax = fig.gca()
> >
> > cmap=get_cmap('reds')
> > plage = arange(0,100,1)
> > surf = contourf(X,Y,F, plage)
> > plage = arange(0,100,2)
> > surf = contour(X,Y,F, plage, linewidths=2)
> >
> > ax.grid(True)
> > fig.colorbar(surf, shrink=0.5, aspect=5)
> > axis([x.min(),x.max(),y.min(),y.max()])
> >
> > show()
> >
> >
> > I ran it with pyV2.6/matplotlibV0.99.1, and it behaves differently with
> > pyV2.7/matplotlibV1.1.0 .
> >
> > Could you confirm that on your computer, if this is an expected
> > behaviour, and, if not, if you have an idea about how to fix it ?
> >
> > thanks a lot,
> > Arnaud.
> >
> >
> >
> >
> > --
> > All the data continuously generated in your IT infrastructure
> > contains a definitive record of customers, application performance,
> > security threats, fraudulent activity, and more. Splunk takes this
> > data and makes sense of it. IT sense. And common sense.
> > http://p.sf.net/sfu/splunk-novd2d
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> --
> Cloud Services Checklist: Pricing and Packaging Optimization
> This white paper is intended to serve as a reference, checklist and point of 
> discussion for anyone considering optimizing the pricing and packaging model 
> of a cloud services business. Read Now!
> http://www.accelacomm.com/jaw/sfnl/114/51491232/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot_surface fails with log axes ?

2011-12-06 Thread Arnaud
Hello,

i encountered a problem when trying to set axes as logarithmic in a 3D
plot using plot_surface().

I do not know if it is a known bug or if it is a workaround ...?
the failing code is : 
#!/usr/bin/python
import os
import sys
from pylab import *
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import axes3d
import numpy as np 
# parameters we bach on
X = np.arange(0.1, 20, 0.5)
Y = np.arange(0.1, 20, 0.5)
X, Y = np.meshgrid(X, Y)
R = np.sqrt((X-10)**2 + (Y-10)**2)
Z = np.sin(R)

fig = figure(num=None, figsize=(6, 6), dpi=80, facecolor='#F2F2F2',
edgecolor='k')
ax = subplot(111,projection='3d')

# the two following  make the plot fail
#ax.set_yscale('log')
ax.set_xscale('log')

ax.plot_surface(X,Y,Z, rstride=1, cstride=1, cmap=cm.jet, linewidths=.5)

show()

and the complete output is : 
Traceback (most recent call last):
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", 
line 395, in expose_event
self._render_figure(self._pixmap, w, h)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", 
line 75, in _render_figure
FigureCanvasAgg.draw(self)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 401, in draw
self.figure.draw(self.renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py",
line 884, in draw
func(*args)
  File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py",
line 210, in draw
ax.draw(renderer)
  File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py",
line 393, in draw
tick.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/axis.py", line
234, in draw
self.label1.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/text.py", line
591, in draw
ismath=ismath)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 142, in draw_text
return self.draw_mathtext(gc, x, y, s, prop, angle)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 131, in draw_mathtext
x = int(x) + ox
  File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line
3795, in __int__
raise MaskError, 'Cannot convert masked element to a Python int.'
numpy.ma.core.MaskError: Cannot convert masked element to a Python int.
Traceback (most recent call last):
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", 
line 395, in expose_event
self._render_figure(self._pixmap, w, h)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", 
line 75, in _render_figure
FigureCanvasAgg.draw(self)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 401, in draw
self.figure.draw(self.renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py",
line 884, in draw
func(*args)
  File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py",
line 210, in draw
ax.draw(renderer)
  File
"/usr/local/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py",
line 393, in draw
tick.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/axis.py", line
234, in draw
self.label1.draw(renderer)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/artist.py",
line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/text.py", line
591, in draw
ismath=ismath)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 142, in draw_text
return self.draw_mathtext(gc, x, y, s, prop, angle)
  File
"/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", 
line 131, in draw_mathtext
x = int(x) + ox
  File "/usr/local/lib/python2.7/site-packages/numpy/ma/core.py", line
3795, in __int__
   

Re: [Matplotlib-users] plot_surface fails with log axes ?

2011-12-06 Thread Arnaud
thanks, of course, this work.
I will have to edit ticks labels ...

shall we expect a correction in near future ?

best,
-- 
RHENOVIA - Arnaud LEGENDRE.


Le mardi 06 décembre 2011 à 10:45 -0600, Benjamin Root a écrit :
> On Tue, Dec 6, 2011 at 10:08 AM, Arnaud 
> wrote:
> Hello,
> 
> i encountered a problem when trying to set axes as logarithmic
> in a 3D
> plot using plot_surface().
> 
> I do not know if it is a known bug or if it is a
> workaround ...?
> 
> Yes, this is a known bug and it is a very tricky one to untangle.  My
> only suggestion is to plot the function using linearized log values.
> So, maybe something like this:
> 
> #!/usr/bin/python
> import os
> import sys
> from pylab import *
> from mpl_toolkits.mplot3d import Axes3D
> from mpl_toolkits.mplot3d import axes3d
> import numpy as np
> # parameters we bach on
> X = np.log10(np.arange(0.1, 20, 0.5))
> Y = np.log10(np.arange(0.1, 20, 0.5))
> X, Y = np.meshgrid(X, Y)
> R = np.sqrt((10**X-10)**2 + (10**Y-10)**2)
> Z = np.sin(R)
> 
> fig = figure(num=None, figsize=(6, 6), dpi=80, facecolor='#F2F2F2',
> edgecolor='k')
> ax = subplot(111,projection='3d')
> ax.plot_surface(X,Y,Z, rstride=1, cstride=1, cmap=cm.jet,
> linewidths=.5)
> 
> show()
> 
> Now, that won't make the points evenly spaced, so you might want to do
> something like the following:
> 
> X = np.log10(np.logspace(-1, 1.3, 40))
> 
> I hope that helps!
> Ben Root
> 


--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] zooming with transforms

2012-03-27 Thread Arnaud Gardelein
What is the most effective approach to perform a 'zoom under mouse
cursor'? Currently I use the following code (considering g as mpl.Axes),
but set_xlim() is called twice. Is there a better approach?


# First zoom
result = \
g.bbox.shrunk(DEFAULT_ZOOM_FACTOR,1).transformed(g.transData.inverted())
g.set_xlim(*result.intervalx)
# Get the new location of initial event
b = g.transData.transform_point([event.xdata, 0])
# Then replace the original location under the mouse cursor
result = \
g.bbox.translated(-(event.x-b[0]),0).transformed(g.transData.inverted())
g.set_xlim(*result.intervalx)


Arnaud.



--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] zooming with transforms

2012-03-30 Thread Arnaud Gardelein
What is the most effective approach to perform a 'zoom under mouse
cursor'? Currently I use the following code (considering g as mpl.Axes),
but set_xlim() is called twice. Is there a better approach?


# First zoom
result = \
g.bbox.shrunk(DEFAULT_ZOOM_FACTOR,1).transformed(g.transData.inverted())
g.set_xlim(*result.intervalx)
# Get the new location of initial event
b = g.transData.transform_point([event.xdata, 0])
# Then replace the original location under the mouse cursor
result = \
g.bbox.translated(-(event.x-b[0]),0).transformed(g.transData.inverted())
g.set_xlim(*result.intervalx)


Arnaud.


--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users