[Matplotlib-users] Plot aliasing

2008-12-27 Thread Kaushik Ghose
Hi Gang,

I was plotting some data collected from an ADC and noticed an odd aliasing 
issue. Please see the images on the following site.

http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html

I wonder if there is any way to avoid this kind of aliasing. I vaguely remember 
our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's 
plotting to be superior to MATLAB's in every way (except for 3D) and it would 
be 
nice if aliasing could be handled gracefully.

Also, thanks for the excellent binary packages for Mac!

Many thanks
-Kaushik

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plot aliasing

2008-12-27 Thread John Hunter
On Sat, Dec 27, 2008 at 10:29 AM, Kaushik Ghose
 wrote:
> Hi Gang,
>
> I was plotting some data collected from an ADC and noticed an odd aliasing
> issue. Please see the images on the following site.
>
> http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html
>
> I wonder if there is any way to avoid this kind of aliasing. I vaguely 
> remember
> our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's
> plotting to be superior to MATLAB's in every way (except for 3D) and it would 
> be
> nice if aliasing could be handled gracefully.

I'm almost certain this is a result of the path simplification logic.
Could you upload some sample data and a self contained script so we
can test?
You can test this by editing site-packages/path.py and replacing::

  self.should_simplify = (len(vertices) >= 128 and
(codes is None or np.all(codes <= Path.LINETO)))

with::

  self.should_simplify = False

Michael, perhaps we could override path.should_simplify with an rc or
line property?

> Also, thanks for the excellent binary packages for Mac!

Thanks for testing them!

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plot aliasing

2008-12-27 Thread Kaushik Ghose
Hi John,

OK. I've managed to pare it down to the following pattern:

import pylab

N = 1000
x = pylab.zeros(200)
x[1] = .5
x[2:24] = 1.0
x[24] = .5
x[26] = -.5
x[27:49] = -1.0
x[49] = -.5
x = pylab.tile(x, 100)
pylab.plot(x)


The above code is sufficient to repeat the glitch (just resize the window to 
check this). The half-way values (0.5) are important - if we have a straight 
jump   the glitch isn't visible.

I'm sorry but I couldn't find path.py under

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/

so I couldn't try it out. (Is it under a different place in mac?)

thanks
-Kaushik



John Hunter wrote:
> On Sat, Dec 27, 2008 at 10:29 AM, Kaushik Ghose
>  wrote:
>> Hi Gang,
>>
>> I was plotting some data collected from an ADC and noticed an odd aliasing
>> issue. Please see the images on the following site.
>>
>> http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html
>>
>> I wonder if there is any way to avoid this kind of aliasing. I vaguely 
>> remember
>> our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's
>> plotting to be superior to MATLAB's in every way (except for 3D) and it 
>> would be
>> nice if aliasing could be handled gracefully.
> 
> I'm almost certain this is a result of the path simplification logic.
> Could you upload some sample data and a self contained script so we
> can test?
> You can test this by editing site-packages/path.py and replacing::
> 
>   self.should_simplify = (len(vertices) >= 128 and
> (codes is None or np.all(codes <= 
> Path.LINETO)))
> 
> with::
> 
>   self.should_simplify = False
> 
> Michael, perhaps we could override path.should_simplify with an rc or
> line property?
> 
>> Also, thanks for the excellent binary packages for Mac!
> 
> Thanks for testing them!

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plot aliasing

2008-12-27 Thread Kaushik Ghose
PS. In the code just disregard the line N = 1000 - it does nothing.

Ghose, Kaushik wrote:
> Hi John,
> 
> OK. I've managed to pare it down to the following pattern:
> 
> import pylab
> 
> N = 1000
> x = pylab.zeros(200)
> x[1] = .5
> x[2:24] = 1.0
> x[24] = .5
> x[26] = -.5
> x[27:49] = -1.0
> x[49] = -.5
> x = pylab.tile(x, 100)
> pylab.plot(x)
> 
> 
> The above code is sufficient to repeat the glitch (just resize the window to
> check this). The half-way values (0.5) are important - if we have a straight
> jump   the glitch isn't visible.
> 
> I'm sorry but I couldn't find path.py under
> 
> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/
> 
> so I couldn't try it out. (Is it under a different place in mac?)
> 
> thanks
> -Kaushik
> 
> 
> 
> John Hunter wrote:
>> On Sat, Dec 27, 2008 at 10:29 AM, Kaushik Ghose
>>  wrote:
>>> Hi Gang,
>>>
>>> I was plotting some data collected from an ADC and noticed an odd aliasing
>>> issue. Please see the images on the following site.
>>>
>>> http://assorted-experience.blogspot.com/2008/12/odd-aliasing-issue-with-matplotlib.html
>>>
>>> I wonder if there is any way to avoid this kind of aliasing. I vaguely 
>>> remember
>>> our old arch-foe (MATLAB) handles this gracefully. I have found matplotlib's
>>> plotting to be superior to MATLAB's in every way (except for 3D) and it 
>>> would be
>>> nice if aliasing could be handled gracefully.
>> I'm almost certain this is a result of the path simplification logic.
>> Could you upload some sample data and a self contained script so we
>> can test?
>> You can test this by editing site-packages/path.py and replacing::
>>
>>   self.should_simplify = (len(vertices) >= 128 and
>> (codes is None or np.all(codes <= 
>> Path.LINETO)))
>>
>> with::
>>
>>   self.should_simplify = False
>>
>> Michael, perhaps we could override path.should_simplify with an rc or
>> line property?
>>
>>> Also, thanks for the excellent binary packages for Mac!
>> Thanks for testing them!
> 
> --
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plotting NOAA data...

2008-12-27 Thread antonv

It seems that I just cannot grasp the way the data needs to be formatted for
this to work...
I've used the griddata sample that James posted but it takes about 10
minutes to prep the data for plotting so that solution seems to be out of
discussion.

I guess my issue is that I don't know what type of data is required by
contourf function. Also as Jeff was saying earlier, the data is read from a
grib file so supposedly it's already gridded. I've also looked at the
basemap demo
(http://matplotlib.sourceforge.net/users/screenshots.html#basemap-demo) and
the data is read from 3 files, one for Lat one for Long and the Last for Z
Data. Is there a way to automatically extract the data from the grib file to
a format similar to the one used in the basemap example?



Jeff Whitaker wrote:
> 
> Mauro Cavalcanti wrote:
>> Dear Anton,
>>
>> 2008/12/23 antonv :
>>   
>>>  Also, because I figured out the data I need and already have the
>>> scripts in place
>>> to extract the CSV files I would really like to keep it that way. Would
>>> it be possible to
>>> just show me how to get from the csv file to the plot?
>>> 
>>
>> Here is a short recipe:
>>
>> import numpy as np
>>
>> f = open("file.csv", "r")
>> coords = np.loadtxt(f, delimiter=",", skiprows=1)
>> lon = coords[:,0]
>> lat = coords[:,1]
>> dat = coords[:,2]
>>
>> where "file.csv" is a regular comma-separated values file in the format:
>>
>> Lat,Lon,Dat
>> -61.05,10.4,20
>> -79.43,9.15,50
>> -70.66,9.53,10
>> -63.11,7.91,40
>> ...
>>
>> Hope this helps!
>>
>> Best regards,
>>
>>   
> Since the arrays are 2D (for gridded data), a reshape is also needed, i.e.
> 
> lon.shape = (nlats,nlons)
> lat.shape = (nlats,nlons)
> data.shape = (nlats,nlons)
> 
> You'll  need to know what the grid dimensons (nlats,nlons) are.
> 
> -Jeff
> 
> --
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21190078.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users