Re: [Matplotlib-users] Information request
Hi Jeff, I have put the code online with a sample of the data here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to give me some advice as it is quite difficult for someone new in python and scientific computation Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 10 septembre 2008 16:45 To: Antoine De Pauw Cc: Matplotlib Users Subject: Re: Information request Antoine De Pauw wrote: > Thanks Jeff, > > In fact my points are arranged in three unsorted arrays, with a simple scheme (thats why I couldn't plot them with imshow and others) > > arrays: > > [lat][lon][val] > [-10][ 17][0.3] > [ 37][ 23][3.7] > ... ... ... > > and so for many rows... > > what I have to do is looping through my arrays like that > > while i < rowcount: > plot_to_map(lat[i],lon[i],val[i]) > > it is evidently an idea of how it could be done easily but my knowledge of these libraries is too weak for me to figure out how to do it > > my data comes from huge binary files but is extremely simple, so it would be really easy for anyone to help me as the problem itself is how to put unsorted points on the map with latitude and longitude coordinates > Antoine: You haven't said if your data forms a rectangular array. If so, you can build a 2-d array from the input file and plot it with imshow. If not, you can still plug the elements into a 2-d masked array, leaving the missing pixels masked. You say the points are 'unsorted', does that mean they are randomly distributed and do not form a rectangular grid? It would really be much easier to help if you gave us more information, such as how the data is structured, what the pixel footprint is, etc. Perhaps you could post the binary file on an ftp site somewhere with code to read it. Also, please hit 'reply all' when replying, so the matplotlib users mailing list is CC'ed. -Jeff >> Antoine De Pauw wrote: >>> Sir, >>> >>> I'm sorry, as english is not my mothertongue and it is sometimes difficult to be understandable. >>> >>> All is in the script I gave to you initially, except the point drawing code which would be useless as it is proven not to work (I dont know the method to do it). >>> >>> What I have is a map, and a set of pixels I have to put on it with geographic coordinates. >>> >>> I cannot find the right method to put colour pixels on the map, that's the problem. >>> >>> I have that map in miller projection, and three arrays containing respectively latitude, longitude and satellite measured value. >>> >>> What I need to obtain is something approximately like this: http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 _00_lr.gif but with the basemap toolkit. >>> >>> So, my question is: how could I do to plot a coloured pixel at coordinates lat:lon on that map? If I have just the method to project a geographic coordinate on the map and put a coloured pixel at the right place, all is done and I just have to loop my arrays... Also, I would have to implement some antialiasing on the map. >>> >> Antoine: >> >> Are the pixels arranged on a regular grid - or are they randomly >> distributed? If they are on a grid, it's easy (using pcolor or imshow). >> >> If you could send me your data I may be able to get you started. >> >> (I'm cc'ing the matplotlib list so others can join in the discussion). >> >> >> -Jeff >>> If this is not possible to do it in a simple and explainable way, please tell me and I'll continue using matlab or searching for the bit of code which will save me >>> >>> Anyway, I have to thank you for your interest to help me.. >>> >>> Many thanks, >>> >>> Antoine De Pauw >>> >>> Antoine De Pauw wrote: > Hi, and thanks for the answer > > In fact, what I do is reading a binary file to obtain 3 arrays (Lat,Lon,Val) describing geographic points which are associated by index (like point 1 is Lat[0]:Lon[0] with value Val[0]) > > What I need to do is to plot some points on the map (miller projection for most) based on latitude and longitude, to obtain a colour map (points are unordered, it is from IASI satellite computations) > > I'm able to create a map, draw simple things on it, etc but the problem I have is any method I try for plotting points is failing, either pcolor, pcolormesh, imshow, etc. > > When I found your post on that mailing list, I figured out that you might have the experience and skills to easily explain to me how to manipulate these points and plot them on the map, as there's like no help on the web except standard examples... > > Please tell me if this is possible for you to give me some tips, or if it takes too much of your time just advice me some lectu
[Matplotlib-users] windrose OO
Hi all, with few free hours, I have modified the windrose file to be O.O. compliant with the 0.98 matplotlib branch and normally bug free. The next posts will be on sourceforge : https://sourceforge.net/project/showfiles.php?group_id=239240&package_id=290902 and to see it in detail, here is the entry on blogspot: http://youarealegend.blogspot.com/2008/09/windrose.html All suggestion welcome (even to correct my bad english ;-) ) Thanks to the best python plotting library and the matplotlib team! -- Lionel Roubeyrie - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: > Hi Jeff, > > I have put the code online with a sample of the data here: > > http://snipplr.com/view/8307/map-plotting-python-code-temporary/ > > I hope you'll be able to give me some advice as it is quite difficult for > someone new in python and scientific computation > Antoine: How big are the pixels? Is the text file lon,lat,data or lat,lon,data? -Jeff > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: mercredi 10 septembre 2008 16:45 > To: Antoine De Pauw > Cc: Matplotlib Users > Subject: Re: Information request > > Antoine De Pauw wrote: > >> Thanks Jeff, >> >> In fact my points are arranged in three unsorted arrays, with a simple >> > scheme (thats why I couldn't plot them with imshow and others) > >> arrays: >> >> [lat][lon][val] >> [-10][ 17][0.3] >> [ 37][ 23][3.7] >> ... ... ... >> >> and so for many rows... >> >> what I have to do is looping through my arrays like that >> >> while i < rowcount: >> plot_to_map(lat[i],lon[i],val[i]) >> >> it is evidently an idea of how it could be done easily but my knowledge of >> > these libraries is too weak for me to figure out how to do it > >> my data comes from huge binary files but is extremely simple, so it would >> > be really easy for anyone to help me as the problem itself is how to put > unsorted points on the map with latitude and longitude coordinates > > > Antoine: You haven't said if your data forms a rectangular array. If > so, you can build a 2-d array from the input file and plot it with > imshow. If not, you can still plug the elements into a 2-d masked > array, leaving the missing pixels masked. You say the points are > 'unsorted', does that mean they are randomly distributed and do not form > a rectangular grid? > > It would really be much easier to help if you gave us more information, > such as how the data is structured, what the pixel footprint is, etc. > Perhaps you could post the binary file on an ftp site somewhere with > code to read it. > > Also, please hit 'reply all' when replying, so the matplotlib users > mailing list is CC'ed. > > -Jeff > >>> Antoine De Pauw wrote: >>> Sir, I'm sorry, as english is not my mothertongue and it is sometimes > difficult to be understandable. > All is in the script I gave to you initially, except the point drawing > code which would be useless as it is proven not to work (I dont know the > method to do it). > What I have is a map, and a set of pixels I have to put on it with > geographic coordinates. > I cannot find the right method to put colour pixels on the map, that's > the problem. > I have that map in miller projection, and three arrays containing > respectively latitude, longitude and satellite measured value. > What I need to obtain is something approximately like this: > http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 > _00_lr.gif but with the basemap toolkit. > So, my question is: how could I do to plot a coloured pixel at > coordinates lat:lon on that map? If I have just the method to project a > geographic coordinate on the map and put a coloured pixel at the right > place, all is done and I just have to loop my arrays... Also, I would have > to implement some antialiasing on the map. > >>> Antoine: >>> >>> Are the pixels arranged on a regular grid - or are they randomly >>> distributed? If they are on a grid, it's easy (using pcolor or imshow). >>> >>> If you could send me your data I may be able to get you started. >>> >>> (I'm cc'ing the matplotlib list so others can join in the discussion). >>> >>> >>> -Jeff >>> If this is not possible to do it in a simple and explainable way, please > tell me and I'll continue using matlab or searching for the bit of code > which will save me > Anyway, I have to thank you for your interest to help me.. Many thanks, Antoine De Pauw > Antoine De Pauw wrote: > > >> Hi, and thanks for the answer >> >> In fact, what I do is reading a binary file to obtain 3 arrays >> > (Lat,Lon,Val) describing geographic points which are associated by index > (like point 1 is Lat[0]:Lon[0] with value Val[0]) > >> What I need to do is to plot some points on the map (miller projection >> > for most) based on latitude and longitude, to obtain a colour map (points > are unordered, it is from IASI satellite computations) > >> I'm able to create a
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: > Hi Jeff, > > I have put the code online with a sample of the data here: > > http://snipplr.com/view/8307/map-plotting-python-code-temporary/ > > I hope you'll be able to give me some advice as it is quite difficult for > someone new in python and scientific computation > > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > Antoine: I may have the size of the pixels wrong, and lat/lon transposed, but this is the general idea: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np lats = []; lons = []; data = [] for line in open('pixels.dat'): linesplit = line.split(',') lons.append(float(linesplit[1])) lats.append(float(linesplit[0])) data.append(float(linesplit[2])) map = Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') x,y = map(lons,lats) plt.scatter(x,y,s=25,c=data,marker='s',edgecolor="None",cmap=plt.cm.jet) plt.colorbar(shrink=0.6) map.drawcoastlines() plt.show() -Jeff > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: mercredi 10 septembre 2008 16:45 > To: Antoine De Pauw > Cc: Matplotlib Users > Subject: Re: Information request > > Antoine De Pauw wrote: > >> Thanks Jeff, >> >> In fact my points are arranged in three unsorted arrays, with a simple >> > scheme (thats why I couldn't plot them with imshow and others) > >> arrays: >> >> [lat][lon][val] >> [-10][ 17][0.3] >> [ 37][ 23][3.7] >> ... ... ... >> >> and so for many rows... >> >> what I have to do is looping through my arrays like that >> >> while i < rowcount: >> plot_to_map(lat[i],lon[i],val[i]) >> >> it is evidently an idea of how it could be done easily but my knowledge of >> > these libraries is too weak for me to figure out how to do it > >> my data comes from huge binary files but is extremely simple, so it would >> > be really easy for anyone to help me as the problem itself is how to put > unsorted points on the map with latitude and longitude coordinates > > > Antoine: You haven't said if your data forms a rectangular array. If > so, you can build a 2-d array from the input file and plot it with > imshow. If not, you can still plug the elements into a 2-d masked > array, leaving the missing pixels masked. You say the points are > 'unsorted', does that mean they are randomly distributed and do not form > a rectangular grid? > > It would really be much easier to help if you gave us more information, > such as how the data is structured, what the pixel footprint is, etc. > Perhaps you could post the binary file on an ftp site somewhere with > code to read it. > > Also, please hit 'reply all' when replying, so the matplotlib users > mailing list is CC'ed. > > -Jeff > >>> Antoine De Pauw wrote: >>> Sir, I'm sorry, as english is not my mothertongue and it is sometimes > difficult to be understandable. > All is in the script I gave to you initially, except the point drawing > code which would be useless as it is proven not to work (I dont know the > method to do it). > What I have is a map, and a set of pixels I have to put on it with > geographic coordinates. > I cannot find the right method to put colour pixels on the map, that's > the problem. > I have that map in miller projection, and three arrays containing > respectively latitude, longitude and satellite measured value. > What I need to obtain is something approximately like this: > http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 > _00_lr.gif but with the basemap toolkit. > So, my question is: how could I do to plot a coloured pixel at > coordinates lat:lon on that map? If I have just the method to project a > geographic coordinate on the map and put a coloured pixel at the right > place, all is done and I just have to loop my arrays... Also, I would have > to implement some antialiasing on the map. > >>> Antoine: >>> >>> Are the pixels arranged on a regular grid - or are they randomly >>> distributed? If they are on a grid, it's easy (using pcolor or imshow). >>> >>> If you could send me your data I may be able to get you started. >>> >>> (I'm cc'ing the matplotlib list so others can join in the discussion). >>> >>> >>> -Jeff >>> If this is not possible to do it in a simple and explainable way, please > tell me and I'll continue using matlab or searching for the bit of code > which will save me > Anyway, I have to thank you for your interest to help me.. Many thanks,
Re: [Matplotlib-users] Information request
Thanks Jeff, This seems to work with csv file types, and I've been experimenting a bit with it However, when I try to implement this with my original code (with binary files), I get an error like that one: Traceback (most recent call last): File "C:\Python25\Projects\FigPlot\FigPlot.py", line 39, in x,y = map(Lon,Lat) TypeError: 'numpy.ndarray' object is not callable I think this is coming from the fact I use array objects to store values... could you confirm it? Also, I'll see if it is possible to invert color scale and mask everything under a certain value Thanks very much for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 14:10 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: > Hi Jeff, > > I have put the code online with a sample of the data here: > > http://snipplr.com/view/8307/map-plotting-python-code-temporary/ > > I hope you'll be able to give me some advice as it is quite difficult for > someone new in python and scientific computation > > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > Antoine: I may have the size of the pixels wrong, and lat/lon transposed, but this is the general idea: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np lats = []; lons = []; data = [] for line in open('pixels.dat'): linesplit = line.split(',') lons.append(float(linesplit[1])) lats.append(float(linesplit[0])) data.append(float(linesplit[2])) map = Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') x,y = map(lons,lats) plt.scatter(x,y,s=25,c=data,marker='s',edgecolor="None",cmap=plt.cm.jet) plt.colorbar(shrink=0.6) map.drawcoastlines() plt.show() -Jeff > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: mercredi 10 septembre 2008 16:45 > To: Antoine De Pauw > Cc: Matplotlib Users > Subject: Re: Information request > > Antoine De Pauw wrote: > >> Thanks Jeff, >> >> In fact my points are arranged in three unsorted arrays, with a simple >> > scheme (thats why I couldn't plot them with imshow and others) > >> arrays: >> >> [lat][lon][val] >> [-10][ 17][0.3] >> [ 37][ 23][3.7] >> ... ... ... >> >> and so for many rows... >> >> what I have to do is looping through my arrays like that >> >> while i < rowcount: >> plot_to_map(lat[i],lon[i],val[i]) >> >> it is evidently an idea of how it could be done easily but my knowledge of >> > these libraries is too weak for me to figure out how to do it > >> my data comes from huge binary files but is extremely simple, so it would >> > be really easy for anyone to help me as the problem itself is how to put > unsorted points on the map with latitude and longitude coordinates > > > Antoine: You haven't said if your data forms a rectangular array. If > so, you can build a 2-d array from the input file and plot it with > imshow. If not, you can still plug the elements into a 2-d masked > array, leaving the missing pixels masked. You say the points are > 'unsorted', does that mean they are randomly distributed and do not form > a rectangular grid? > > It would really be much easier to help if you gave us more information, > such as how the data is structured, what the pixel footprint is, etc. > Perhaps you could post the binary file on an ftp site somewhere with > code to read it. > > Also, please hit 'reply all' when replying, so the matplotlib users > mailing list is CC'ed. > > -Jeff > >>> Antoine De Pauw wrote: >>> Sir, I'm sorry, as english is not my mothertongue and it is sometimes > difficult to be understandable. > All is in the script I gave to you initially, except the point drawing > code which would be useless as it is proven not to work (I dont know the > method to do it). > What I have is a map, and a set of pixels I have to put on it with > geographic coordinates. > I cannot find the right method to put colour pixels on the map, that's > the problem. > I have that map in miller projection, and three arrays containing > respectively latitude, longitude and satellite measured value. > What I need to obtain is something approximately like this: > http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 > _00_lr.gif
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: > Thanks Jeff, > > This seems to work with csv file types, and I've been experimenting a bit > with it > > However, when I try to implement this with my original code (with binary > files), I get an error like that one: > > Traceback (most recent call last): > File "C:\Python25\Projects\FigPlot\FigPlot.py", line 39, in > x,y = map(Lon,Lat) > TypeError: 'numpy.ndarray' object is not callable > > I think this is coming from the fact I use array objects to store values... > could you confirm it? > Antoine: It looks like you the object map is not a Basemap instance, but a numpy array. Try putting 'print type(map)' just ahead of this statement to verify this. I suspect your re-using the name 'map' in your code, overwriting the Basemap class instance. -Jeff > Also, I'll see if it is possible to invert color scale and mask everything > under a certain value > > Thanks very much for your help! > > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > > > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: jeudi 11 septembre 2008 14:10 > To: De Pauw Antoine > Cc: 'Matplotlib Users' > Subject: Re: [Matplotlib-users] Information request > > De Pauw Antoine wrote: > >> Hi Jeff, >> >> I have put the code online with a sample of the data here: >> >> http://snipplr.com/view/8307/map-plotting-python-code-temporary/ >> >> I hope you'll be able to give me some advice as it is quite difficult for >> someone new in python and scientific computation >> >> Antoine De Pauw >> Collaborateur de recherches, Informatique - Research collaborator, IT >> Laboratoire de chimie quantique et photophysique - Quantum chemistry and >> photophysics laboratory >> Université Libre de Bruxelles - ULB >> >> > > Antoine: I may have the size of the pixels wrong, and lat/lon > transposed, but this is the general idea: > > from mpl_toolkits.basemap import Basemap > import matplotlib.pyplot as plt > import numpy as np > lats = []; lons = []; data = [] > for line in open('pixels.dat'): > linesplit = line.split(',') > lons.append(float(linesplit[1])) > lats.append(float(linesplit[0])) > data.append(float(linesplit[2])) > map = > Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ > > urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') > x,y = map(lons,lats) > plt.scatter(x,y,s=25,c=data,marker='s',edgecolor="None",cmap=plt.cm.jet) > plt.colorbar(shrink=0.6) > map.drawcoastlines() > plt.show() > > -Jeff > > >> -Original Message- >> From: Jeff Whitaker [mailto:[EMAIL PROTECTED] >> Sent: mercredi 10 septembre 2008 16:45 >> To: Antoine De Pauw >> Cc: Matplotlib Users >> Subject: Re: Information request >> >> Antoine De Pauw wrote: >> >> >>> Thanks Jeff, >>> >>> In fact my points are arranged in three unsorted arrays, with a simple >>> >>> >> scheme (thats why I couldn't plot them with imshow and others) >> >> >>> arrays: >>> >>> [lat][lon][val] >>> [-10][ 17][0.3] >>> [ 37][ 23][3.7] >>> ... ... ... >>> >>> and so for many rows... >>> >>> what I have to do is looping through my arrays like that >>> >>> while i < rowcount: >>> plot_to_map(lat[i],lon[i],val[i]) >>> >>> it is evidently an idea of how it could be done easily but my knowledge >>> > of > >>> >>> >> these libraries is too weak for me to figure out how to do it >> >> >>> my data comes from huge binary files but is extremely simple, so it would >>> >>> >> be really easy for anyone to help me as the problem itself is how to put >> unsorted points on the map with latitude and longitude coordinates >> >> >> Antoine: You haven't said if your data forms a rectangular array. If >> so, you can build a 2-d array from the input file and plot it with >> imshow. If not, you can still plug the elements into a 2-d masked >> array, leaving the missing pixels masked. You say the points are >> 'unsorted', does that mean they are randomly distributed and do not form >> a rectangular grid? >> >> It would really be much easier to help if you gave us more information, >> such as how the data is structured, what the pixel footprint is, etc. >> Perhaps you could post the binary file on an ftp site somewhere with >> code to read it. >> >> Also, please hit 'reply all' when replying, so the matplotlib users >> mailing list is CC'ed. >> >> -Jeff >> >> Antoine De Pauw wrote: > Sir, > > I'm sorry, as english is not my mothertongue and it is sometimes > > >> difficult to be understandable. >> >> > All is in the script I gave to you initially, except the point drawing > > >> code whi
Re: [Matplotlib-users] Information request
Jeff, The map object is from the Basemap type, the only different thing is the Lon,Lat and Val objects which are from the type array instead of lists Anyway, solutions are slowly showing themselves and I thank you all Have a nice day Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 15:29 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: > Thanks Jeff, > > This seems to work with csv file types, and I've been experimenting a bit > with it > > However, when I try to implement this with my original code (with binary > files), I get an error like that one: > > Traceback (most recent call last): > File "C:\Python25\Projects\FigPlot\FigPlot.py", line 39, in > x,y = map(Lon,Lat) > TypeError: 'numpy.ndarray' object is not callable > > I think this is coming from the fact I use array objects to store values... > could you confirm it? > Antoine: It looks like you the object map is not a Basemap instance, but a numpy array. Try putting 'print type(map)' just ahead of this statement to verify this. I suspect your re-using the name 'map' in your code, overwriting the Basemap class instance. -Jeff > Also, I'll see if it is possible to invert color scale and mask everything > under a certain value > > Thanks very much for your help! > > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > > > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: jeudi 11 septembre 2008 14:10 > To: De Pauw Antoine > Cc: 'Matplotlib Users' > Subject: Re: [Matplotlib-users] Information request > > De Pauw Antoine wrote: > >> Hi Jeff, >> >> I have put the code online with a sample of the data here: >> >> http://snipplr.com/view/8307/map-plotting-python-code-temporary/ >> >> I hope you'll be able to give me some advice as it is quite difficult for >> someone new in python and scientific computation >> >> Antoine De Pauw >> Collaborateur de recherches, Informatique - Research collaborator, IT >> Laboratoire de chimie quantique et photophysique - Quantum chemistry and >> photophysics laboratory >> Université Libre de Bruxelles - ULB >> >> > > Antoine: I may have the size of the pixels wrong, and lat/lon > transposed, but this is the general idea: > > from mpl_toolkits.basemap import Basemap > import matplotlib.pyplot as plt > import numpy as np > lats = []; lons = []; data = [] > for line in open('pixels.dat'): > linesplit = line.split(',') > lons.append(float(linesplit[1])) > lats.append(float(linesplit[0])) > data.append(float(linesplit[2])) > map = > Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ > > urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') > x,y = map(lons,lats) > plt.scatter(x,y,s=25,c=data,marker='s',edgecolor="None",cmap=plt.cm.jet) > plt.colorbar(shrink=0.6) > map.drawcoastlines() > plt.show() > > -Jeff > > >> -Original Message- >> From: Jeff Whitaker [mailto:[EMAIL PROTECTED] >> Sent: mercredi 10 septembre 2008 16:45 >> To: Antoine De Pauw >> Cc: Matplotlib Users >> Subject: Re: Information request >> >> Antoine De Pauw wrote: >> >> >>> Thanks Jeff, >>> >>> In fact my points are arranged in three unsorted arrays, with a simple >>> >>> >> scheme (thats why I couldn't plot them with imshow and others) >> >> >>> arrays: >>> >>> [lat][lon][val] >>> [-10][ 17][0.3] >>> [ 37][ 23][3.7] >>> ... ... ... >>> >>> and so for many rows... >>> >>> what I have to do is looping through my arrays like that >>> >>> while i < rowcount: >>> plot_to_map(lat[i],lon[i],val[i]) >>> >>> it is evidently an idea of how it could be done easily but my knowledge >>> > of > >>> >>> >> these libraries is too weak for me to figure out how to do it >> >> >>> my data comes from huge binary files but is extremely simple, so it would >>> >>> >> be really easy for anyone to help me as the problem itself is how to put >> unsorted points on the map with latitude and longitude coordinates >> >> >> Antoine: You haven't said if your data forms a rectangular array. If >> so, you can build a 2-d array from the input file and plot it with >> imshow. If not, you can still plug the elements into a 2-d masked >> array, leaving the missing pixels masked. You say the points are >> 'unsorted', does that mean they are randomly distributed and do not form >> a rectangular grid? >> >> It would really be much easier to help if you
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: > Jeff, > > The map object is from the Basemap type, the only different thing is the > Lon,Lat and Val objects which are from the type array instead of lists > > Anyway, solutions are slowly showing themselves and I thank you all > > Have a nice day > > Antoine De Pauw > Collaborateur de recherches, Informatique - Research collaborator, IT > Laboratoire de chimie quantique et photophysique - Quantum chemistry and > photophysics laboratory > Université Libre de Bruxelles - ULB > Antoine: It should not matter if Lon and Lat are python arrays, lists or numpy arrays. The Basemap instance __call__ method handles them all. There must be something else going on. It is always better to post actual code so we can see what is happening and test it ourselves. -Jeff > > -Original Message- > From: Jeff Whitaker [mailto:[EMAIL PROTECTED] > Sent: jeudi 11 septembre 2008 15:29 > To: De Pauw Antoine > Cc: 'Matplotlib Users' > Subject: Re: [Matplotlib-users] Information request > > De Pauw Antoine wrote: > >> Thanks Jeff, >> >> This seems to work with csv file types, and I've been experimenting a bit >> with it >> >> However, when I try to implement this with my original code (with binary >> files), I get an error like that one: >> >> Traceback (most recent call last): >> File "C:\Python25\Projects\FigPlot\FigPlot.py", line 39, in >> x,y = map(Lon,Lat) >> TypeError: 'numpy.ndarray' object is not callable >> >> I think this is coming from the fact I use array objects to store >> > values... > >> could you confirm it? >> >> > > Antoine: It looks like you the object map is not a Basemap instance, > but a numpy array. Try putting 'print type(map)' just ahead of this > statement to verify this. I suspect your re-using the name 'map' in your > code, overwriting the Basemap class instance. > > -Jeff > >> Also, I'll see if it is possible to invert color scale and mask everything >> under a certain value >> >> Thanks very much for your help! >> >> Antoine De Pauw >> Collaborateur de recherches, Informatique - Research collaborator, IT >> Laboratoire de chimie quantique et photophysique - Quantum chemistry and >> photophysics laboratory >> Université Libre de Bruxelles - ULB >> >> >> -Original Message- >> From: Jeff Whitaker [mailto:[EMAIL PROTECTED] >> Sent: jeudi 11 septembre 2008 14:10 >> To: De Pauw Antoine >> Cc: 'Matplotlib Users' >> Subject: Re: [Matplotlib-users] Information request >> >> De Pauw Antoine wrote: >> >> >>> Hi Jeff, >>> >>> I have put the code online with a sample of the data here: >>> >>> http://snipplr.com/view/8307/map-plotting-python-code-temporary/ >>> >>> I hope you'll be able to give me some advice as it is quite difficult for >>> someone new in python and scientific computation >>> >>> Antoine De Pauw >>> Collaborateur de recherches, Informatique - Research collaborator, IT >>> Laboratoire de chimie quantique et photophysique - Quantum chemistry and >>> photophysics laboratory >>> Université Libre de Bruxelles - ULB >>> >>> >>> >> Antoine: I may have the size of the pixels wrong, and lat/lon >> transposed, but this is the general idea: >> >> from mpl_toolkits.basemap import Basemap >> import matplotlib.pyplot as plt >> import numpy as np >> lats = []; lons = []; data = [] >> for line in open('pixels.dat'): >> linesplit = line.split(',') >> lons.append(float(linesplit[1])) >> lats.append(float(linesplit[0])) >> data.append(float(linesplit[2])) >> map = >> Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ >> >> urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') >> x,y = map(lons,lats) >> plt.scatter(x,y,s=25,c=data,marker='s',edgecolor="None",cmap=plt.cm.jet) >> plt.colorbar(shrink=0.6) >> map.drawcoastlines() >> plt.show() >> >> -Jeff >> >> >> >>> -Original Message- >>> From: Jeff Whitaker [mailto:[EMAIL PROTECTED] >>> Sent: mercredi 10 septembre 2008 16:45 >>> To: Antoine De Pauw >>> Cc: Matplotlib Users >>> Subject: Re: Information request >>> >>> Antoine De Pauw wrote: >>> >>> >>> Thanks Jeff, In fact my points are arranged in three unsorted arrays, with a simple >>> scheme (thats why I couldn't plot them with imshow and others) >>> >>> >>> arrays: [lat][lon][val] [-10][ 17][0.3] [ 37][ 23][3.7] ... ... ... and so for many rows... what I have to do is looping through my arrays like that while i < rowcount: plot_to_map(lat[i],lon[i],val[i]) it is evidently an idea of how it could be done easily but my knowledge >> of >> >> >>> these libraries is too weak for me to figure out how to do it >>> >>> >>> my data comes from huge binary files but is extremely sim
[Matplotlib-users] squishing a plot axis
I've got a pretty standard "plot with a title" set up, but my title is three lines long, and is pushed off the top of the figure by the layout. How can I "squish" (rescale) the y-axis of my axes to give more room above the figure? How can I add padding around the axes in the figure? (For now, I've decreased the font size of the title, but this is suboptimal.) Thanks. ~jon - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] squishing a plot axis
On Thu, Sep 11, 2008 at 10:19 AM, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > I've got a pretty standard "plot with a title" set up, but my title is > three lines long, and is pushed off the top of the figure by the > layout. > > How can I "squish" (rescale) the y-axis of my axes to give more room > above the figure? How can I add padding around the axes in the figure? fig = plt.figure() fig.subplots_adjust(top=0.8) JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib qt4 backend: QScrollArea
Hi everyone, I would like to create a plot in matplotlib using a lot of subplots but I would like to attach QScrollArea to this. Do you guys have any idea of how can I do it? I did it with an image but it doesn't work when I try to include the FigureCanvas object to the QScrollArea. Thanks! Bernardo M. Rocha - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Interactive animation
I'm trying to develop an application for interactive graph layout using networkx and matplotlib. My idea is to use the usual spring layout, where nodes repel each other and edges act as attractive forces between nodes, but have the layout happen in real time on the screen. The user can also interact with the layout by dragging the nodes and the graph will respond again in real time. I've worked my way through the interactive and animation examples for matplotlib, which seem fine but I can't figure out how to combine them. What I'd like to get me started is to attach an event listener to the plot in anim.py so I can start and stop it with a mouse or key event. Can anybody point me in the right direction? Thanks, Peter - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Interactive animation
On Thu, Sep 11, 2008 at 10:51 AM, Peter Saffrey <[EMAIL PROTECTED]> wrote: > I'm trying to develop an application for interactive graph layout using > networkx and matplotlib. My idea is to use the usual spring layout, > where nodes repel each other and edges act as attractive forces between > nodes, but have the layout happen in real time on the screen. The user > can also interact with the layout by dragging the nodes and the graph > will respond again in real time. > > I've worked my way through the interactive and animation examples for > matplotlib, which seem fine but I can't figure out how to combine them. > What I'd like to get me started is to attach an event listener to the > plot in anim.py so I can start and stop it with a mouse or key event. > Can anybody point me in the right direction? There is an example in the event handling docs called "draggable rectangle exercise" that shows you how to combine event handling with animation (see the "extra credit solution") http://matplotlib.sourceforge.net/doc/html/users/event_handling.html - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] legend for bar charts
I have a multicolor bar chart that I create like this: bar(dates*4, b3 + b2 + b1 + b0, color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates) + ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)), width=4) How can I create a legend for this? leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores", "8,192 - 32,767 Cores", "0 - 8,191 Cores"], loc="upper left", shadow=True) Shows the same color for each legend box, presumably because it's the last color used in drawing the "line" in my bar chart. ~jon - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend for bar charts
For the record, I also just tried bar(dates, b3, color='#9E73C1', width=4) bar(dates, b2, color='#A6DE62', width=4) bar(dates, b1, color='#F35E5A', width=4) bar(dates, b0, color='#4992DE', width=4) leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores", "8,192 - 32,767 Cores", "0 - 8,191 Cores"], loc="upper left", shadow=True) And got the same results. (I had thought that multiple bar commands would replace, rather than stack, on a given axis.) ~jon On Thu, Sep 11, 2008 at 1:20 PM, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > I have a multicolor bar chart that I create like this: > > bar(dates*4, b3 + b2 + b1 + b0, >color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates) >+ ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)), >width=4) > > How can I create a legend for this? > >leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores", >"8,192 - 32,767 Cores", "0 - 8,191 Cores"], >loc="upper left", shadow=True) > > Shows the same color for each legend box, presumably because it's the > last color used in drawing the "line" in my bar chart. > > ~jon > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend for bar charts
I eventually did it with b3l = bar(dates, b3, color='#9E73C1', width=4) b2l = bar(dates, b2, color='#A6DE62', width=4) b1l = bar(dates, b1, color='#F35E5A', width=4) b0l = bar(dates, b0, color='#4992DE', width=4) leg = legend([b3l[0], b2l[0], b1l[0], b0l[0]],["98,304 - 163,840 Cores", "32768 - 98,303 Cores", "8,192 - 32,767 Cores", "0 - 8,191 Cores"], loc="upper left", shadow=True) but I would be interested in hearing a better way. ~jon On Thu, Sep 11, 2008 at 1:28 PM, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > For the record, I also just tried > > bar(dates, b3, color='#9E73C1', width=4) >bar(dates, b2, color='#A6DE62', width=4) >bar(dates, b1, color='#F35E5A', width=4) >bar(dates, b0, color='#4992DE', width=4) >leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores", >"8,192 - 32,767 Cores", "0 - 8,191 Cores"], >loc="upper left", shadow=True) > > And got the same results. (I had thought that multiple bar commands > would replace, rather than stack, on a given axis.) > > ~jon > > On Thu, Sep 11, 2008 at 1:20 PM, Jonathon Anderson > <[EMAIL PROTECTED]> wrote: >> I have a multicolor bar chart that I create like this: >> >> bar(dates*4, b3 + b2 + b1 + b0, >>color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates) >>+ ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)), >>width=4) >> >> How can I create a legend for this? >> >>leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores", >>"8,192 - 32,767 Cores", "0 - 8,191 Cores"], >>loc="upper left", shadow=True) >> >> Shows the same color for each legend box, presumably because it's the >> last color used in drawing the "line" in my bar chart. >> >> ~jon >> > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend for bar charts
On Thu, Sep 11, 2008 at 1:33 PM, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > I eventually did it with > >b3l = bar(dates, b3, color='#9E73C1', width=4) >b2l = bar(dates, b2, color='#A6DE62', width=4) >b1l = bar(dates, b1, color='#F35E5A', width=4) >b0l = bar(dates, b0, color='#4992DE', width=4) >leg = legend([b3l[0], b2l[0], b1l[0], b0l[0]],["98,304 - > 163,840 Cores", "32768 - 98,303 Cores", >"8,192 - 32,767 Cores", "0 - 8,191 Cores"], >loc="upper left", shadow=True) > > but I would be interested in hearing a better way. Sorry to be so late in responding -- I missed your earlier posts. The method you found is the suggested one. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug in savefig?
Has anyone reported a bug in the post-script renderer regarding text with backticks in it? I remember that there was a bug fix for single quotes, but I just ran into this one. I'm using 0.98.2 on OS 10.5. A sample script is below. If I try to open the postscript file in Mac's Preview, it attempts to convert it to a PDF before viewing and fails. Similarly, if I try to convert it using ps2pdf, it also fails. #!/usr/bin/python from pylab import * x = array([1,2,3,4]) y = array([5,6,7,8]) plot(x,y,'r+') hold(True) text(2,7,"El `Jamar") savefig('output.eps') savefig('output.png') -- -- Michael Hearne [EMAIL PROTECTED] (303) 273-8620 USGS National Earthquake Information Center 1711 Illinois St. Golden CO 80401 Senior Software Engineer Synergetics, Inc. -- - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug in savefig?
Thanks for reporting this. It is now fixed in SVN r6085. If you're not running SVN, you can apply this patch here: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/backends/backend_ps.py?r1=6080&r2=6085 I'll go ahead and fix this on the maintenance branch too. Cheers, Mike Michael Hearne wrote: > Has anyone reported a bug in the post-script renderer regarding text > with backticks in it? I remember that there was a bug fix for single > quotes, but I just ran into this one. > > I'm using 0.98.2 on OS 10.5. > > A sample script is below. If I try to open the postscript file in Mac's > Preview, it attempts to convert it to a PDF before viewing and fails. > Similarly, if I try to convert it using ps2pdf, it also fails. > > #!/usr/bin/python > > from pylab import * > > x = array([1,2,3,4]) > y = array([5,6,7,8]) > plot(x,y,'r+') > hold(True) > text(2,7,"El `Jamar") > savefig('output.eps') > savefig('output.png') > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] eliminating the top tick on an axis
Hi, I have a very vexing problem. I am using MPL (both 0.98.1 and 0.91.2) to create a vertical stack of three plots with no space in between. In order to do so, I need to eliminate either the top or bottom tick of each plot. I have chosen to eliminate the top tick, and I am doing something like the following: ticks = a.yaxis.get_major_ticks() ticks[-2].set_visible(False) where a is the axis object in question. Most of the time, that works, though I don't know why there is an additional "blank" tick inserted at the top, making the top most visible tick the second to last element in the ticks array.. However, sometimes, that deletes the second tick from the top, leaving the top tick! An example of what I am talking about can be found at http://research.jsoishi.org/images/yavg_t_spectra.png. Note that all of the plots are fine except for the bottom most subpanel of the upper left plot. All subplots in that figure include exactly the two lines above. A simpler test case is the following: --- #!/usr/bin/env python import pylab as P import numpy as N x = N.linspace(0,2*N.pi,1000) y1 = N.sin(x) y2 = N.sinc(x) y3 = N.cos(x) fig = P.figure() for i,y in enumerate([y1,y2,y3]): bot = 0.05+i*0.3 ax = fig.add_axes([0.1,bot,0.8,0.3]) ax.plot(x,y) ticks = ax.yaxis.get_major_ticks() ticks[-1].set_visible(False) # works on the top & bottom plot #ticks[-2].set_visible(False) # works on the middle one if i != 0: ax.set_xticklabels('') fig.savefig('tick_test.png') For me, the ticks[-1] line gives the image at http://research.jsoishi.org/images/tick_test.png, while the commented out ticks[-2] line gives the inverse (the middle plot deletes the top most tick, and the others delete the second from the last). Any help would be greatly appreciated. Jeff - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] boxplot on noisy data
Hi, We're making box plots of weather data, which is notoriously noisy. Different boxes may have different numbers of observations. But boxplot seems to demand that each box represent the same number of values. For example, if day 1 had 5 observations and day 2 had only 4 obs, we'd have the program: import pylab as pb vals = [ [1,2,3,4,5], [10,20,30,40]] pb.boxplot( vals) pb.show() This gives: Traceback (most recent call last): ... ValueError: setting an array element with a sequence. However, if I make the subarrays the same length: vals = [ [1,2,3,4,5], [10,20,30,40,50]] I get FIVE box plots (not 2)! It appears the matlab boxplot converts vals into an array 12345 10 20 30 40 50 and makes a box plot of each COLUMN, not row. How can I get boxplot working with different numbers of observations for each position? Thanks! Steve -- Steve Sullivan [EMAIL PROTECTED] 303-497-2823 FL/2, Research Applications Laboratory National Center for Atmospheric Research PO Box 3000 Boulder CO 80307 USA - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Figure Dimension
Hi All matplotlib users, I want to ask a question about figure dimension (pixels), how to set the figure's dimension that we will create using matlotlib.pyplot.savefig() ? Thank You .. -- Zainal Abidin, S.Si Sub Bidang Informasi Meteorologi Publik Badan Meteorologi dan Geofisika Jl. Angkasa I No. 2 Jakarta - Indonesia *Visit Indonesia Year 2008 - Celebrating 100 Years of National Awakening* - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] eliminating the top tick on an axis
Hi, It seems that there is no guarantee that the get_major_ticks() methods returns only ticks within the view interval, i.e., it can return ticks outside the data limit. As far as I see, this is related with the general behavior of locator objects. For example, In [71]: ax.yaxis.get_view_interval() Out[71]: array([-0.4, 1.2]) In [72]: ax.yaxis.major.locator() Out[72]: array([-0.4, -0.2, 0. , 0.2, 0.4, 0.6, 0.8, 1. , 1.2, 1.4]) So, for the middle axes in your example script, the last tick actually corresponds to 1.4 not 1.2. I guess this is not a bug though. And the draw() method actually checks and only draw those within the view interval. And for your purpose, you may use following function to only select the ticks within the view interval. import matplotlib.transforms as mtransforms def get_major_ticks_within_view_interval(axis): interval = axis.get_view_interval() ticks_in_view_interval = [] for tick, loc in zip(axis.get_major_ticks(), axis.get_major_locator()()): if mtransforms.interval_contains(interval, loc): ticks_in_view_interval.append(tick) return ticks_in_view_interval And, in your example script, use this function as below instead of get_major_ticks() methods. ticks = get_major_ticks_within_view_interval(ax.yaxis) Also, I guess it'd better to have only the label invisible. ticks[-1].label.set_visible(False)\ While I don't think this is a best solution, it seems work okay. I hope this is helpful. -JJ On Thu, Sep 11, 2008 at 6:41 PM, j s oishi <[EMAIL PROTECTED]> wrote: > Hi, > > I have a very vexing problem. I am using MPL (both 0.98.1 and 0.91.2) > to create a vertical stack of three plots with no space in between. In > order to do so, I need to eliminate either the top or bottom tick of > each plot. I have chosen to eliminate the top tick, and I am doing > something like the following: > > ticks = a.yaxis.get_major_ticks() > ticks[-2].set_visible(False) > > where a is the axis object in question. Most of the time, that works, > though I don't know why there is an additional "blank" tick inserted > at the top, making the top most visible tick the second to last > element in the ticks array.. However, sometimes, that deletes the > second tick from the top, leaving the top tick! An example of what I > am talking about can be found at > http://research.jsoishi.org/images/yavg_t_spectra.png. Note that all > of the plots are fine except for the bottom most subpanel of the upper > left plot. All subplots in that figure include exactly the two lines > above. > > A simpler test case is the following: > > --- > #!/usr/bin/env python > > import pylab as P > import numpy as N > > x = N.linspace(0,2*N.pi,1000) > y1 = N.sin(x) > y2 = N.sinc(x) > y3 = N.cos(x) > > fig = P.figure() > > > for i,y in enumerate([y1,y2,y3]): >bot = 0.05+i*0.3 >ax = fig.add_axes([0.1,bot,0.8,0.3]) >ax.plot(x,y) > > >ticks = ax.yaxis.get_major_ticks() >ticks[-1].set_visible(False) # works on the top & bottom plot > #ticks[-2].set_visible(False) # works on the middle one > >if i != 0: >ax.set_xticklabels('') > > fig.savefig('tick_test.png') > > > > For me, the ticks[-1] line gives the image at > http://research.jsoishi.org/images/tick_test.png, while the commented > out ticks[-2] line gives the inverse (the middle plot deletes the top > most tick, and the others delete the second from the last). > > Any help would be greatly appreciated. > > Jeff > > - > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users