bug in fcontour with v1.1.0 ?

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='#666666',
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.

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

···

On 12/05/2011 10:00 AM, Arnaud wrote:

#!/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='#666666',
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

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='#666666',
> 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

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.

That's why the plot looked OK to me, except for the odd colorbar; it never would have occurred to me that you might be using the gtk backend.

The GTK backend is only partially functional, and I don't think it will ever go beyond that. I think we should simply deprecate and then remove it so as to avoid the sort of puzzle you encountered.

Eric

···

On 12/06/2011 12:43 AM, Arnaud wrote:

thanks again for answering!
best