SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

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)




Showing 7 results of 7

From: Samir W. <sam...@gm...> - 2008年09月10日 19:55:20
Hi,
I am trying to draw a rectangle of a fixed size and them put a lable/text on
it. However if the text is too long, it goes out of bounds. Is there a way I
restrict the text within the rectangle margins.
heres what I am using
######################################
 def rectangle(self, lower, upper, node1, branch_name):
 rect = Rectangle(lower, upper[0]-lower[0], upper[1] - lower[1],
 edgecolor='k',
 facecolor= self.color_method(node1))
 self.ax.add_patch(rect)
 self.ax.text(lower[0] + (upper[0]-lower[0])/2, lower[1] +
(upper[1]-lower[1])/2, branch_name, ha='left', va='center',
fontsize='xx-small')
########################################
Any thoughts / suggestion will be really appreciated.
Thanks
samir
From: Antoine De P. <and...@ul...> - 2008年09月10日 15:01:50
in fact the points are not in a rectangular array and pixels are missing, like you said
I'll put the code and binary file online tomorrow as I have not access to it today, but reading it is not the problem
when read, the values are in three arrays of same size, which I will have to convert to a 2D masked array... we'll see tomorrow if I have succeeded
many thanks
>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://wwwoma.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&#8217;m currently trying to improve our plotting tools here at the &#8220;Quantum 
>>>>>>>> Chemistry and Photophysics&#8221; 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&#8230;
>>>>>>>>
>>>>>>>> 
>>>>>>>>
>>>>>>>> Thank you very much in advance,
>>>>>>>>
>>>>>>>> 
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>>
>>>>>>>> 
>>>>>>>>
>>>>>>>> PS: I give you the code I&#8217;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
>
>
From: Jeff W. <Jef...@no...> - 2008年09月10日 14:44:51
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&#8217;m currently trying to improve our plotting tools here at the &#8220;Quantum 
>>>>>>> Chemistry and Photophysics&#8221; 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&#8230;
>>>>>>>
>>>>>>> 
>>>>>>>
>>>>>>> Thank you very much in advance,
>>>>>>>
>>>>>>> 
>>>>>>>
>>>>>>> Best regards,
>>>>>>>
>>>>>>> 
>>>>>>>
>>>>>>> PS: I give you the code I&#8217;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
From: Jeff W. <jef...@no...> - 2008年09月10日 13:41:47
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&#8217;m currently trying to improve our plotting tools here at the &#8220;Quantum 
>>>>> Chemistry and Photophysics&#8221; 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&#8230;
>>>>>
>>>>> 
>>>>>
>>>>> Thank you very much in advance,
>>>>>
>>>>> 
>>>>>
>>>>> Best regards,
>>>>>
>>>>> 
>>>>>
>>>>> PS: I give you the code I&#8217;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
From: Michael D. <md...@st...> - 2008年09月10日 13:22:48
Ah, yes. The code was written with the assumption that the paths were 
treated as filled (which doesn't really matter whether they are closed 
or not). I have added a "filled" kwarg to Path.intersects_path and 
Path.intersects_bbox that when True treats the path(s) as filled, and 
when False does not. In order to not change existing functionality, 
this argument defaults to "True". To resolve Evan's problem, one would 
now explicitly pass "filled=False" to intersects_bbox.
Cheers,
Mike
Eric Firing wrote:
> Michael Droettboom wrote:
>> I just added a test of intersects_bbox to SVN that seems to be 
>> working correctly for short paths containing masked values. It would 
>> appear that masked values *should* be dealt with correctly (that is, 
>> in exactly the same way as they are drawn) by the intersection code. 
>> However, there is probably a side case here that I'm missing. As 
>> Eric suggests, see if you can break it down into a simple example 
>> that fails and hopefully the problem and/or solution will be more 
>> obvious from that.
>
> Mike,
>
> I was wrong; it has nothing to do with masked values. It is much 
> simpler: it appears that for the purpose of this test, the path is 
> being treated as if it were closed. See attached. I think this 
> accounts for Evan's mis-identified tracks.
>
> Eric
>
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Adam <ada...@gm...> - 2008年09月10日 10:04:19
JJ,
Thank you for sharing this. Although I have to admit I'm a bit surprised by
what
it takes to accomplish this, I think I will be able to use your class to do
what I need
to do, or at least get a lot of the way there.
Cheers,
-adam.
On Tue, Sep 9, 2008 at 5:34 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Adam,
>
> I needed a same thing a while ago and I ended up with a custom class.
> Although this need some more work, try and see if it fits your need in
> case you want to avoid the little arithmetic that John mentioned.
> The python file and a example plot are attached.
>
> I wanted the padding between the subaxes is conserved even if the
> figure size changes (and something more), so the implementation got
> little bit hackish and much longer than I initially expected, but it
> works for me.
> A simple use case is included in the file (I'm afraid that there are
> not much documentation).
>
>
> Briefly,
>
>
> import matplotlib.pyplot as plt
> from mpl_multiaxes import MultiPane_Subplot
>
> F = plt.figure(1)
> F.clf()
>
> mp = MultiPane_Subplot(F, subplot_pos=(1, 1, 1),
> nrows_ncols = (3, 2),
> n_pane=5,
> pane_direction="row", # or "column"
> axes_pad_inch=0.0,
> )
>
> F.add_subplot(mp)
>
>
> In the above example, MultiPane_Subplot is a subclass of the Subplot
> which contains subaxes. You set number of rows and columns for your
> subaxes grid. If the number of subaxes is smaller than nrows*ncols,
> you explicitly set it with n_pane.
>
> After this, each subaxes is accessed as mp[0], mp[1], and so on. They
> are subclass of Axes. So you may use any drawing method that Axes
> class has. As mp is subclass of Subplot, it is also an axes. I
> consider it as a kind of master axes. Anything you plot in this axes
> is also drawn in all of its subaxes. Also note that xaxis and yaxis
> are shared among these subaxes, therefore they have same xlim, ylim.
> etc.
>
> Regards,
>
> -JJ
>
>
> On Tue, Sep 9, 2008 at 8:12 AM, Adam <ada...@gm...> wrote:
> >
> > John,
> >
> >> By default, matplotlib will resize your axes to preserve the aspect
> >> ratio of your image, which in the case of your 23x25 images is not
> >> equal. You can override this behavior by setting aspect='auto'
> >>
> >> for i in range(6):
> >> fig1.add_subplot(2,3,i+1)
> >> pylab.imshow(data, aspect='auto')
> >
> > This gets rid of the blank space, but at the expense of the aspect ratio,
> as
> > you mention. Isn't there away to preserve the aspect ratios of the
> > individual
> > sub-images, and just remove the white space between them? I really to
> not
> > want to mess with the images themselves.
> >
> > cheers,
> > adam.
> >
> > -------------------------------------------------------------------------
> > 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
> >
> >
>
From: Eric F. <ef...@ha...> - 2008年09月10日 07:23:18
Attachments: bbox_intersect2.py
Michael Droettboom wrote:
> I just added a test of intersects_bbox to SVN that seems to be working 
> correctly for short paths containing masked values. It would appear 
> that masked values *should* be dealt with correctly (that is, in exactly 
> the same way as they are drawn) by the intersection code. However, 
> there is probably a side case here that I'm missing. As Eric suggests, 
> see if you can break it down into a simple example that fails and 
> hopefully the problem and/or solution will be more obvious from that.
Mike,
I was wrong; it has nothing to do with masked values. It is much 
simpler: it appears that for the purpose of this test, the path is being 
treated as if it were closed. See attached. I think this accounts for 
Evan's mis-identified tracks.
Eric

Showing 7 results of 7

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /