You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(12) |
Sep
(12) |
Oct
(56) |
Nov
(65) |
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(59) |
Feb
(78) |
Mar
(153) |
Apr
(205) |
May
(184) |
Jun
(123) |
Jul
(171) |
Aug
(156) |
Sep
(190) |
Oct
(120) |
Nov
(154) |
Dec
(223) |
2005 |
Jan
(184) |
Feb
(267) |
Mar
(214) |
Apr
(286) |
May
(320) |
Jun
(299) |
Jul
(348) |
Aug
(283) |
Sep
(355) |
Oct
(293) |
Nov
(232) |
Dec
(203) |
2006 |
Jan
(352) |
Feb
(358) |
Mar
(403) |
Apr
(313) |
May
(165) |
Jun
(281) |
Jul
(316) |
Aug
(228) |
Sep
(279) |
Oct
(243) |
Nov
(315) |
Dec
(345) |
2007 |
Jan
(260) |
Feb
(323) |
Mar
(340) |
Apr
(319) |
May
(290) |
Jun
(296) |
Jul
(221) |
Aug
(292) |
Sep
(242) |
Oct
(248) |
Nov
(242) |
Dec
(332) |
2008 |
Jan
(312) |
Feb
(359) |
Mar
(454) |
Apr
(287) |
May
(340) |
Jun
(450) |
Jul
(403) |
Aug
(324) |
Sep
(349) |
Oct
(385) |
Nov
(363) |
Dec
(437) |
2009 |
Jan
(500) |
Feb
(301) |
Mar
(409) |
Apr
(486) |
May
(545) |
Jun
(391) |
Jul
(518) |
Aug
(497) |
Sep
(492) |
Oct
(429) |
Nov
(357) |
Dec
(310) |
2010 |
Jan
(371) |
Feb
(657) |
Mar
(519) |
Apr
(432) |
May
(312) |
Jun
(416) |
Jul
(477) |
Aug
(386) |
Sep
(419) |
Oct
(435) |
Nov
(320) |
Dec
(202) |
2011 |
Jan
(321) |
Feb
(413) |
Mar
(299) |
Apr
(215) |
May
(284) |
Jun
(203) |
Jul
(207) |
Aug
(314) |
Sep
(321) |
Oct
(259) |
Nov
(347) |
Dec
(209) |
2012 |
Jan
(322) |
Feb
(414) |
Mar
(377) |
Apr
(179) |
May
(173) |
Jun
(234) |
Jul
(295) |
Aug
(239) |
Sep
(276) |
Oct
(355) |
Nov
(144) |
Dec
(108) |
2013 |
Jan
(170) |
Feb
(89) |
Mar
(204) |
Apr
(133) |
May
(142) |
Jun
(89) |
Jul
(160) |
Aug
(180) |
Sep
(69) |
Oct
(136) |
Nov
(83) |
Dec
(32) |
2014 |
Jan
(71) |
Feb
(90) |
Mar
(161) |
Apr
(117) |
May
(78) |
Jun
(94) |
Jul
(60) |
Aug
(83) |
Sep
(102) |
Oct
(132) |
Nov
(154) |
Dec
(96) |
2015 |
Jan
(45) |
Feb
(138) |
Mar
(176) |
Apr
(132) |
May
(119) |
Jun
(124) |
Jul
(77) |
Aug
(31) |
Sep
(34) |
Oct
(22) |
Nov
(23) |
Dec
(9) |
2016 |
Jan
(26) |
Feb
(17) |
Mar
(10) |
Apr
(8) |
May
(4) |
Jun
(8) |
Jul
(6) |
Aug
(5) |
Sep
(9) |
Oct
(4) |
Nov
|
Dec
|
2017 |
Jan
(5) |
Feb
(7) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(3) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
1
(2) |
2
(5) |
3
(8) |
4
(6) |
5
(9) |
6
(7) |
7
(6) |
8
(10) |
9
(27) |
10
(7) |
11
(22) |
12
(13) |
13
(7) |
14
(4) |
15
(12) |
16
(32) |
17
(26) |
18
(14) |
19
(1) |
20
(11) |
21
(6) |
22
(11) |
23
(17) |
24
(18) |
25
(28) |
26
(11) |
27
(6) |
28
(1) |
29
(10) |
30
(12) |
|
|
|
|
Jeremy Conlin wrote: > First question: > I know I can do pylab.loglog() to get a log-log plot. I would like to > create a log-linear plot. How can I do this? semilogx or semilogy: semilogy <http://matplotlib.sourceforge.net/matplotlib.pyplot.html#-semilogy>(*args, **kwargs) Make a plot with log scaling on the *y* axis. > > Second question: > I would like to plot two sequences on the same figure with two > different y-scales, one scale shown on the left and one scale shown on > the right. How can I do this? twiny: ax = twiny <http://matplotlib.sourceforge.net/matplotlib.axes.html#Axes-twiny>() create a twin of Axes <http://matplotlib.sourceforge.net/matplotlib.axes.html#Axes> for generating a plot with a shared y-axis but independent x axis. The x-axis of self will have ticks on bottom and the returned axes will have ticks on the top -Jeff > > Thanks in advance, > Jeremy > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
First question:I know I can do pylab.loglog() to get a log-log plot. I would like to create a log-linear plot. How can I do this? Second question: I would like to plot two sequences on the same figure with two different y-scales, one scale shown on the left and one scale shown on the right. How can I do this? Thanks in advance, Jeremy
Marjolaine, Getting rid of rows/columns in your case might be a bit tricky, as there's nothing to ensure that your domain is actually square. First, create your mask: lon_mask = (lon >= min_lon) & (lon <= max_lon) lat_mask = (lat >= min_lat) & (lat <= max_lat) glb_mask = lon_mask & lat_mask glb_mask is 2D, with True where the data is selected and False otherwise. Of course, that'll only work if the initial arrays have the same shape. Now, you can check whether all the rows are False (no data selected) row_clipper = glb_mask.any(axis=1) row_clipper is 1D, with the same length as glb_mask, and False where now data is selectd and True otherwise: we can use row_clipper to select only the rows that have at least one unmasked data: clipped_rows = original_array[row_clipper] Then, rinse and repeat, this time on the columns: col_clipper = glb_mask.any(axis=0) clipped_cols = clipped_rows.T[col_clipper].T Note the double .T. You can also decide to use .all instead of any, to select the rows/cols where all data are valid. Let us know how it works. P. On Friday 12 September 2008 10:02:56 Marjolaine Rouault wrote: > Hi, > > I was wondering if the matplotlib users would be able to help with a numpy > problem. > > I have 2 dimensional arrays of latitudes and longitude named lon and lat > and only want to extract lats and lons within a certain domain > It is easy to apply the mask > > lonMask = (lon >= minLon) & (lon <= maxLon) > latMask = (lat >= minLat) & (lat <= maxLat) > > MyNewArray = putmask(originalArray,lonMask*latMask) > > But I am not sure how to clip rows and column of mask data to reduce size > of resulting array. > > The compress, extract etc functions all seem to work with 1D arrays and I > don;t know how to get from my 1D array back to a 2D array. > > I hope this is making sense. > > Marjolaine.
>> 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. I had this problem just recently... It wasn't so much the box plot as the numpy array. I ended up plotting a list of numpy arrays of different lengths, rather than a single 2 dimensional array. Try: vals = [numpy.array([1,2,3,4,5]),numpy.array([10,20,30,40])] and see if it works? Eric
Hi, I was wondering if the matplotlib users would be able to help with a numpy problem. I have 2 dimensional arrays of latitudes and longitude named lon and lat and only want to extract lats and lons within a certain domain It is easy to apply the mask lonMask = (lon >= minLon) & (lon <= maxLon) latMask = (lat >= minLat) & (lat <= maxLat) MyNewArray = putmask(originalArray,lonMask*latMask) But I am not sure how to clip rows and column of mask data to reduce size of resulting array. The compress, extract etc functions all seem to work with 1D arrays and I don;t know how to get from my 1D array back to a 2D array. I hope this is making sense. Marjolaine. -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.
Thanks Jeff, Antialiasing is not very useful as my pixel size is small... also, I used octagon shapes to have a smoother picture Now I'm looking for suppressing pixels under (or over) a certain value, but a couple hours of searching and testing didn't help... I'll see Monday if I find some tips Have a nice weekend 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:js...@fa...] Sent: vendredi 12 septembre 2008 13:26 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: > Hi Jeff, > > I updated my code snippet and uploaded the image I created with a complete > set of data: > > http://snipplr.com/view/8307/map-plotting-python-code-temporary/ > > And here's the picture generated: > > http://www.kirikoo.net/images/5shrad-20080912-105759.png > > I now understand the process and I'm able to reproduce it for other > datasets, but I need to implement some antialiasing for it.. > > Is it possible to do? > > Many thanks for your precious 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 > Antoine: If you do >>> from pylab import scatter >>> help(scatter) you will see that scatter takes an antialised keyword antialiased Boolean or sequence of booleans -Jeff > > -----Original Message----- > From: Jeff Whitaker [mailto:js...@fa...] > Sent: jeudi 11 septembre 2008 16:48 > To: De Pauw Antoine > Cc: 'Matplotlib Users' > Subject: 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:js...@fa...] >> 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 <module> >>> 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:js...@fa...] >>> 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:Jef...@no...] >>>> 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 lectures >>>> >>>> >>>> >>>> >>>>>>>>> Best regards, >>>>>>>>> >>>>>>>>> De Pauw Antoine >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> Antoine: It would really help to have a script demonstrating your >>>>>>>> problem. It sounds to me like you want to plot markers representing >>>>>>>> >>>>>>>> >> a >> >> >>>>>>>> >>>>>>>> >>>>>>>> >>> >>> >>> >>>>>>>> set of points - for that you should use the scatter method. pcolor, >>>>>>>> > > >>>>>>>> pcolormesh and friends are for plotting gridded data. >>>>>>>> >>>>>>>> -Jeff >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> De Pauw Antoine wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Dear sir, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> I’m currently trying to improve our plotting tools here at >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> the >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> “Quantum >>>> >>>> >>>> >>>> >>>>>>>>>>> Chemistry and Photophysics” section of the Université Libre >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> de >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> >>>> >>>> >>>> >>>>>>>>>>> Bruxelles, and I ran, after many time passed at searching for a >>>>>>>>>>> solution, on an explanation from you here: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> http://www.nabble.com/Re:-matplotlib-basemap-question-tt17759370.html >>>> >>>> >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> It seems that you could help me find a solution, as I cannot plot >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> any >>>> >>>> >>>> >>>> >>>>>>>>>>> points on maps. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Could you please tell me what I could do to plot data in a simple >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> way, >>>> >>>> >>>> >>>> >>>>>>>>>>> assuming I have 3 unordered arrays containing respectively >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> latitude, >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> >>>> >>>> >>>> >>>>>>>>>>> longitude and values to plot? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Some tips would be very nice from you as any method I have tried >>>>>>>>>>> >>>>>>>>>>> >> so >> >> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> far >>>> >>>> >>>> >>>> >>>>>>>>>>> give me some errors… >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thank you very much in advance, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Best regards, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> PS: I give you the code I’m using currently, missing the >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> plotting part >>>> >>>> >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> from mpl_toolkits.basemap import Basemap >>>>>>>>>>> >>>>>>>>>>> from numpy import * >>>>>>>>>>> >>>>>>>>>>> from scipy.io.numpyio import fread >>>>>>>>>>> >>>>>>>>>>> import matplotlib.pyplot as plt >>>>>>>>>>> >>>>>>>>>>> import numpy as np >>>>>>>>>>> >>>>>>>>>>> import os >>>>>>>>>>> >>>>>>>>>>> import sys >>>>>>>>>>> >>>>>>>>>>> import array >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> fileName="c:/20080821.b56" >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> print('preparing map') >>>>>>>>>>> >>>>>>>>>>> map = >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> > Basemap(projection='mill',lat_0=0,lon_0=0,resolution='i',area_thresh=30000.) > >> >> >>> >>> >>> >>>> >>>> >>>> >>>> >>>>>>>>>>> map.drawcoastlines(0.5,antialiased=1) >>>>>>>>>>> >>>>>>>>>>> map.drawmapboundary() >>>>>>>>>>> >>>>>>>>>>> #map.drawmeridians(np.arange(-180,180,60),linewidth=0.5, >>>>>>>>>>> labels=np.arange(-180,180,60), labelstyle="+/-") >>>>>>>>>>> >>>>>>>>>>> #map.drawparallels(np.arange(-90,90,30), linewidth=0.5, >>>>>>>>>>> labels=np.arange(-180,180,30), labelstyle="+/-") >>>>>>>>>>> >>>>>>>>>>> print('reading binary data') >>>>>>>>>>> >>>>>>>>>>> nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) >>>>>>>>>>> >>>>>>>>>>> Lat=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> Lon=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> Val=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> rawfile=fromfile(open(fileName,'rb'),'d',-1) >>>>>>>>>>> >>>>>>>>>>> Lat=rawfile[0:nbreligne] >>>>>>>>>>> >>>>>>>>>>> Lon=rawfile[nbreligne:nbreligne*2] >>>>>>>>>>> >>>>>>>>>>> Val=rawfile[nbreligne*21:nbreligne*22] >>>>>>>>>>> >>>>>>>>>>> print('shifting latitudes and projecting to map') >>>>>>>>>>> >>>>>>>>>>> i=0 >>>>>>>>>>> >>>>>>>>>>> while i < nbreligne: >>>>>>>>>>> >>>>>>>>>>> if(Lon[i]>180): >>>>>>>>>>> >>>>>>>>>>> print(Lon[i]) >>>>>>>>>>> >>>>>>>>>>> Lon[i]-=360 >>>>>>>>>>> >>>>>>>>>>> print(Lon[i]) >>>>>>>>>>> >>>>>>>>>>> i+=1 >>>>>>>>>>> >>>>>>>>>>> print('plotting data') >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> #plotting code comes here >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> Antoine: If you send me a self-contained script that produces the >>>>>>>>>> > > >>>>>>>>>> problem you see, I can help you debug it. As it stands now, I >>>>>>>>>> > have > >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> very >>>> >>>> >>>> >>>> >>>>>>>>>> little to work with - it could be your plotting commands, or it >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> could >>> >>> >>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> be >>>> >>>> >>>> >>>> >>>>>>>>>> your data. >>>>>>>>>> >>>>>>>>>> -Jeff >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> print('saving map') >>>>>>>>>>> >>>>>>>>>>> plt.savefig("testfig.png",dpi=600) >>>>>>>>>>> >>>>>>>>>>> print('done') >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> *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 <http://ww.ulb.ac.be/>* >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>>>>> Meteorologist FAX : (303)497-6449 >>>>>>>>>> NOAA/OAR/PSD R/PSD1 Email : Jef...@no... >>>>>>>>>> 325 Broadway Office : Skaggs Research Cntr 1D-113 >>>>>>>>>> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> -- >>>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> -- >>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> >>> >>> >>> >> >> > > > -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328
On 2008年9月11日 21:02:30 -0600, Steve Sullivan <st...@uc...> wrote: > 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. This example works fine for me using matplotlib version 0.98.3 and I've also made many boxplots with unequal numbers of elements with earlier matplotlib versions.
De Pauw Antoine wrote: > Hi Jeff, > > I updated my code snippet and uploaded the image I created with a complete > set of data: > > http://snipplr.com/view/8307/map-plotting-python-code-temporary/ > > And here's the picture generated: > > http://www.kirikoo.net/images/5shrad-20080912-105759.png > > I now understand the process and I'm able to reproduce it for other > datasets, but I need to implement some antialiasing for it.. > > Is it possible to do? > > Many thanks for your precious 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 > Antoine: If you do >>> from pylab import scatter >>> help(scatter) you will see that scatter takes an antialised keyword antialiased Boolean or sequence of booleans -Jeff > > -----Original Message----- > From: Jeff Whitaker [mailto:js...@fa...] > Sent: jeudi 11 septembre 2008 16:48 > To: De Pauw Antoine > Cc: 'Matplotlib Users' > Subject: 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:js...@fa...] >> 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 <module> >>> 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:js...@fa...] >>> 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:Jef...@no...] >>>> 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 lectures >>>> >>>> >>>> >>>> >>>>>>>>> Best regards, >>>>>>>>> >>>>>>>>> De Pauw Antoine >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> Antoine: It would really help to have a script demonstrating your >>>>>>>> problem. It sounds to me like you want to plot markers representing >>>>>>>> >>>>>>>> >> a >> >> >>>>>>>> >>>>>>>> >>>>>>>> >>> >>> >>> >>>>>>>> set of points - for that you should use the scatter method. pcolor, >>>>>>>> > > >>>>>>>> pcolormesh and friends are for plotting gridded data. >>>>>>>> >>>>>>>> -Jeff >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> De Pauw Antoine wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Dear sir, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> I’m currently trying to improve our plotting tools here at >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> the >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> “Quantum >>>> >>>> >>>> >>>> >>>>>>>>>>> Chemistry and Photophysics” section of the Université Libre >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> de >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> >>>> >>>> >>>> >>>>>>>>>>> Bruxelles, and I ran, after many time passed at searching for a >>>>>>>>>>> solution, on an explanation from you here: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> http://www.nabble.com/Re:-matplotlib-basemap-question-tt17759370.html >>>> >>>> >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> It seems that you could help me find a solution, as I cannot plot >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> any >>>> >>>> >>>> >>>> >>>>>>>>>>> points on maps. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Could you please tell me what I could do to plot data in a simple >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> way, >>>> >>>> >>>> >>>> >>>>>>>>>>> assuming I have 3 unordered arrays containing respectively >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>> latitude, >>> >>> >>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> >>>> >>>> >>>> >>>>>>>>>>> longitude and values to plot? >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Some tips would be very nice from you as any method I have tried >>>>>>>>>>> >>>>>>>>>>> >> so >> >> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> far >>>> >>>> >>>> >>>> >>>>>>>>>>> give me some errors… >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Thank you very much in advance, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Best regards, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> PS: I give you the code I’m using currently, missing the >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>> plotting part >>>> >>>> >>>> >>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> from mpl_toolkits.basemap import Basemap >>>>>>>>>>> >>>>>>>>>>> from numpy import * >>>>>>>>>>> >>>>>>>>>>> from scipy.io.numpyio import fread >>>>>>>>>>> >>>>>>>>>>> import matplotlib.pyplot as plt >>>>>>>>>>> >>>>>>>>>>> import numpy as np >>>>>>>>>>> >>>>>>>>>>> import os >>>>>>>>>>> >>>>>>>>>>> import sys >>>>>>>>>>> >>>>>>>>>>> import array >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> fileName="c:/20080821.b56" >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> print('preparing map') >>>>>>>>>>> >>>>>>>>>>> map = >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> > Basemap(projection='mill',lat_0=0,lon_0=0,resolution='i',area_thresh=30000.) > >> >> >>> >>> >>> >>>> >>>> >>>> >>>> >>>>>>>>>>> map.drawcoastlines(0.5,antialiased=1) >>>>>>>>>>> >>>>>>>>>>> map.drawmapboundary() >>>>>>>>>>> >>>>>>>>>>> #map.drawmeridians(np.arange(-180,180,60),linewidth=0.5, >>>>>>>>>>> labels=np.arange(-180,180,60), labelstyle="+/-") >>>>>>>>>>> >>>>>>>>>>> #map.drawparallels(np.arange(-90,90,30), linewidth=0.5, >>>>>>>>>>> labels=np.arange(-180,180,30), labelstyle="+/-") >>>>>>>>>>> >>>>>>>>>>> print('reading binary data') >>>>>>>>>>> >>>>>>>>>>> nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) >>>>>>>>>>> >>>>>>>>>>> Lat=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> Lon=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> Val=zeros(nbreligne) >>>>>>>>>>> >>>>>>>>>>> rawfile=fromfile(open(fileName,'rb'),'d',-1) >>>>>>>>>>> >>>>>>>>>>> Lat=rawfile[0:nbreligne] >>>>>>>>>>> >>>>>>>>>>> Lon=rawfile[nbreligne:nbreligne*2] >>>>>>>>>>> >>>>>>>>>>> Val=rawfile[nbreligne*21:nbreligne*22] >>>>>>>>>>> >>>>>>>>>>> print('shifting latitudes and projecting to map') >>>>>>>>>>> >>>>>>>>>>> i=0 >>>>>>>>>>> >>>>>>>>>>> while i < nbreligne: >>>>>>>>>>> >>>>>>>>>>> if(Lon[i]>180): >>>>>>>>>>> >>>>>>>>>>> print(Lon[i]) >>>>>>>>>>> >>>>>>>>>>> Lon[i]-=360 >>>>>>>>>>> >>>>>>>>>>> print(Lon[i]) >>>>>>>>>>> >>>>>>>>>>> i+=1 >>>>>>>>>>> >>>>>>>>>>> print('plotting data') >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> #plotting code comes here >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> Antoine: If you send me a self-contained script that produces the >>>>>>>>>> > > >>>>>>>>>> problem you see, I can help you debug it. As it stands now, I >>>>>>>>>> > have > >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> very >>>> >>>> >>>> >>>> >>>>>>>>>> little to work with - it could be your plotting commands, or it >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> could >>> >>> >>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>> be >>>> >>>> >>>> >>>> >>>>>>>>>> your data. >>>>>>>>>> >>>>>>>>>> -Jeff >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> print('saving map') >>>>>>>>>>> >>>>>>>>>>> plt.savefig("testfig.png",dpi=600) >>>>>>>>>>> >>>>>>>>>>> print('done') >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> *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 <http://ww.ulb.ac.be/>* >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>>>>> Meteorologist FAX : (303)497-6449 >>>>>>>>>> NOAA/OAR/PSD R/PSD1 Email : Jef...@no... >>>>>>>>>> 325 Broadway Office : Skaggs Research Cntr 1D-113 >>>>>>>>>> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> -- >>>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> -- >>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> >>> >>> >>> >> >> > > > -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328
Hi Jeff, I updated my code snippet and uploaded the image I created with a complete set of data: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ And here's the picture generated: http://www.kirikoo.net/images/5shrad-20080912-105759.png I now understand the process and I'm able to reproduce it for other datasets, but I need to implement some antialiasing for it.. Is it possible to do? Many thanks for your precious 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:js...@fa...] Sent: jeudi 11 septembre 2008 16:48 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: 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:js...@fa...] > 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 <module> >> 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:js...@fa...] >> 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:Jef...@no...] >>> 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 lectures >>> >>> >>> >>>>>>>> Best regards, >>>>>>>> >>>>>>>> De Pauw Antoine >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> Antoine: It would really help to have a script demonstrating your >>>>>>> problem. It sounds to me like you want to plot markers representing >>>>>>> > a > >>>>>>> >>>>>>> >> >> >>>>>>> set of points - for that you should use the scatter method. pcolor, >>>>>>> pcolormesh and friends are for plotting gridded data. >>>>>>> >>>>>>> -Jeff >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> De Pauw Antoine wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> Dear sir, >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> I’m currently trying to improve our plotting tools here at >>>>>>>>>> >>>>>>>>>> >> the >> >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> “Quantum >>> >>> >>> >>>>>>>>>> Chemistry and Photophysics” section of the Université Libre >>>>>>>>>> >>>>>>>>>> >> de >> >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> >>> >>> >>>>>>>>>> Bruxelles, and I ran, after many time passed at searching for a >>>>>>>>>> solution, on an explanation from you here: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> http://www.nabble.com/Re:-matplotlib-basemap-question-tt17759370.html >>> >>> >>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> It seems that you could help me find a solution, as I cannot plot >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> any >>> >>> >>> >>>>>>>>>> points on maps. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Could you please tell me what I could do to plot data in a simple >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> way, >>> >>> >>> >>>>>>>>>> assuming I have 3 unordered arrays containing respectively >>>>>>>>>> >>>>>>>>>> >> latitude, >> >> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> >>> >>> >>>>>>>>>> longitude and values to plot? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Some tips would be very nice from you as any method I have tried >>>>>>>>>> > so > >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> far >>> >>> >>> >>>>>>>>>> give me some errors… >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thank you very much in advance, >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Best regards, >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> PS: I give you the code I’m using currently, missing the >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>> plotting part >>> >>> >>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> from mpl_toolkits.basemap import Basemap >>>>>>>>>> >>>>>>>>>> from numpy import * >>>>>>>>>> >>>>>>>>>> from scipy.io.numpyio import fread >>>>>>>>>> >>>>>>>>>> import matplotlib.pyplot as plt >>>>>>>>>> >>>>>>>>>> import numpy as np >>>>>>>>>> >>>>>>>>>> import os >>>>>>>>>> >>>>>>>>>> import sys >>>>>>>>>> >>>>>>>>>> import array >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> fileName="c:/20080821.b56" >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> print('preparing map') >>>>>>>>>> >>>>>>>>>> map = >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> > Basemap(projection='mill',lat_0=0,lon_0=0,resolution='i',area_thresh=30000.) > >> >> >>> >>> >>> >>>>>>>>>> map.drawcoastlines(0.5,antialiased=1) >>>>>>>>>> >>>>>>>>>> map.drawmapboundary() >>>>>>>>>> >>>>>>>>>> #map.drawmeridians(np.arange(-180,180,60),linewidth=0.5, >>>>>>>>>> labels=np.arange(-180,180,60), labelstyle="+/-") >>>>>>>>>> >>>>>>>>>> #map.drawparallels(np.arange(-90,90,30), linewidth=0.5, >>>>>>>>>> labels=np.arange(-180,180,30), labelstyle="+/-") >>>>>>>>>> >>>>>>>>>> print('reading binary data') >>>>>>>>>> >>>>>>>>>> nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) >>>>>>>>>> >>>>>>>>>> Lat=zeros(nbreligne) >>>>>>>>>> >>>>>>>>>> Lon=zeros(nbreligne) >>>>>>>>>> >>>>>>>>>> Val=zeros(nbreligne) >>>>>>>>>> >>>>>>>>>> rawfile=fromfile(open(fileName,'rb'),'d',-1) >>>>>>>>>> >>>>>>>>>> Lat=rawfile[0:nbreligne] >>>>>>>>>> >>>>>>>>>> Lon=rawfile[nbreligne:nbreligne*2] >>>>>>>>>> >>>>>>>>>> Val=rawfile[nbreligne*21:nbreligne*22] >>>>>>>>>> >>>>>>>>>> print('shifting latitudes and projecting to map') >>>>>>>>>> >>>>>>>>>> i=0 >>>>>>>>>> >>>>>>>>>> while i < nbreligne: >>>>>>>>>> >>>>>>>>>> if(Lon[i]>180): >>>>>>>>>> >>>>>>>>>> print(Lon[i]) >>>>>>>>>> >>>>>>>>>> Lon[i]-=360 >>>>>>>>>> >>>>>>>>>> print(Lon[i]) >>>>>>>>>> >>>>>>>>>> i+=1 >>>>>>>>>> >>>>>>>>>> print('plotting data') >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> #plotting code comes here >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> Antoine: If you send me a self-contained script that produces the >>>>>>>>> problem you see, I can help you debug it. As it stands now, I have >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> very >>> >>> >>> >>>>>>>>> little to work with - it could be your plotting commands, or it >>>>>>>>> >>>>>>>>> >> could >> >> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> be >>> >>> >>> >>>>>>>>> your data. >>>>>>>>> >>>>>>>>> -Jeff >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> print('saving map') >>>>>>>>>> >>>>>>>>>> plt.savefig("testfig.png",dpi=600) >>>>>>>>>> >>>>>>>>>> print('done') >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> *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 <http://ww.ulb.ac.be/>* >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> -- >>>>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>>>> Meteorologist FAX : (303)497-6449 >>>>>>>>> NOAA/OAR/PSD R/PSD1 Email : Jef...@no... >>>>>>>>> 325 Broadway Office : Skaggs Research Cntr 1D-113 >>>>>>>>> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> -- >>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> -- >>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >> >> > > > -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/PSD R/PSD1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
On vendredi 12 septembre 2008, Zainal Abidin wrote: > 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 .. You create explicitely the figure before doing any drawing, and you read the documentation for figure(..): http://matplotlib.sourceforge.net/matplotlib.pyplot.html#-figure You want to change the figsize and dpi keywords. hth, Vincent -- Vincent Favre-Nicolin http://vincefn.net Université Joseph Fourier http://www.ujf-grenoble.fr CEA/ Institut Nanosciences & Cryogénie http://inac.cea.fr ObjCryst & Fox http://objcryst.sourceforge.net
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 <js...@gm...> 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
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*
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 1 2 3 4 5 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 st...@uc... 303-497-2823 FL/2, Research Applications Laboratory National Center for Atmospheric Research PO Box 3000 Boulder CO 80307 USA