Re: [Matplotlib-users] How to draw a specific country by basemap?

2011-01-27 Thread Eric Liang
On 01/27/2011 01:38 AM, Thomas Lecocq wrote:
> Hi,
>
> An easy way is to use the data from http://www.gadm.org/ and to plot
> it with m.readshapefile()
Thank you very much. The GDAM database is great.

BTW,  would you like to give some suggestions about how to color the
map, i.e., highlight a specific region? 

Thanks,
Eric

>
> HTH,
>
> Thom
>
> **
> Thomas Lecocq
> Geologist
> Ph.D.Student (Seismology)
> Royal Observatory of Belgium
> **
>
>
>
> 
> Date: Wed, 26 Jan 2011 16:03:27 +0800
> From: [email protected]
> To: [email protected]
> Subject: [Matplotlib-users] How to draw a specific country by basemap?
>
> Hi all,
>
> I'm using the Basemap module in matplotlib, it's great to draw a world
> map but for a specific country. Empirically, one can draw its own
> country by specifying the lats and longs like this example:
>
> http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html
>
> And you can use the method: drawcontries() to draw the country
> boundries, but all the countries are in the same colour. Does anyone
> know how to highlight a specific country? Thanks in advance.
>
> Eric
> -- 
> -BEGIN GEEK CODE BLOCK-
> Version: 3.1
> GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
> M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
> r !y+
> --END GEEK CODE BLOCK--
>
> --
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better
> price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer
> expires February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> ___ Matplotlib-users
> mailing list [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users 


-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
r !y+
--END GEEK CODE BLOCK--

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to draw a specific country by basemap?

2011-01-27 Thread Thomas Lecocq

Hi, 

that would do:
 
data = m.readshapefile(r'borders\ita_adm1','itaborder',linewidth=0.5)
italy = data[4]
print dir(italy)
italy.set_facecolors('red')
italy.set_alpha(0.5)

 
I think at some point you"ll meet the limitations of the method, you might need 
to use another shapefile-reading module ...
 
Thom
 

**
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**


 


Date: Thu, 27 Jan 2011 17:59:03 +0800
From: [email protected]
To: [email protected]
CC: [email protected]; [email protected]
Subject: Re: [Matplotlib-users] How to draw a specific country by basemap?


On 01/27/2011 01:38 AM, Thomas Lecocq wrote: 


Hi,

An easy way is to use the data from http://www.gadm.org/ and to plot it with 
m.readshapefile()
Thank you very much. The GDAM database is great.

BTW,  would you like to give some suggestions about how to color the map, i.e., 
highlight a specific region?  

Thanks,
Eric



HTH,

Thom

**
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**





Date: Wed, 26 Jan 2011 16:03:27 +0800
From: [email protected]
To: [email protected]
Subject: [Matplotlib-users] How to draw a specific country by basemap?

Hi all,

I'm using the Basemap module in matplotlib, it's great to draw a world map but 
for a specific country. Empirically, one can draw its own country by specifying 
the lats and longs like this example:

http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html
And you can use the method: drawcontries() to draw the country boundries, but 
all the countries are in the same colour. Does anyone know how to highlight a 
specific country? Thanks in advance.

Eric
-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
r !y+
--END GEEK CODE BLOCK--
-- 
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a 
world-class log management solution at an even better price-free! Download 
using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure 
your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
___ Matplotlib-users mailing list 
[email protected] 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
r !y+
--END GEEK CODE BLOCK--   --
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to draw a specific country by basemap?

2011-01-27 Thread Thomas Lecocq

Hi,
 
Adding some extra work in the readshapefile method in your code allows you to 
play with the region names etc,...
 
I've just made a new tutorial script to show this :
 
http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/
 
 
Thom
 

**
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**


 


Date: Thu, 27 Jan 2011 17:59:03 +0800
From: [email protected]
To: [email protected]
CC: [email protected]; [email protected]
Subject: Re: [Matplotlib-users] How to draw a specific country by basemap?

On 01/27/2011 01:38 AM, Thomas Lecocq wrote: 


Hi,

An easy way is to use the data from http://www.gadm.org/ and to plot it with 
m.readshapefile()
Thank you very much. The GDAM database is great.

BTW,  would you like to give some suggestions about how to color the map, i.e., 
highlight a specific region?  

Thanks,
Eric



HTH,

Thom

**
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**





Date: Wed, 26 Jan 2011 16:03:27 +0800
From: [email protected]
To: [email protected]
Subject: [Matplotlib-users] How to draw a specific country by basemap?

Hi all,

I'm using the Basemap module in matplotlib, it's great to draw a world map but 
for a specific country. Empirically, one can draw its own country by specifying 
the lats and longs like this example:

http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html
And you can use the method: drawcontries() to draw the country boundries, but 
all the countries are in the same colour. Does anyone know how to highlight a 
specific country? Thanks in advance.

Eric
-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
r !y+
--END GEEK CODE BLOCK--
-- 
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a 
world-class log management solution at an even better price-free! Download 
using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure 
your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
___ Matplotlib-users mailing list 
[email protected] 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+>++ L++ E++ W++ N+ o+>++ K+++ w !O
M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+>* tv@ b DI-- D G++ e++>+++@ h*
r !y+
--END GEEK CODE BLOCK--
-- 
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a 
world-class log management solution at an even better price-free! Download 
using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure 
your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
___ Matplotlib-users mailing list 
[email protected] 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users   
 --
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Extending readshapefile

2011-01-27 Thread Thomas Lecocq

Hi all,

I would like to contribute to a better readshapefile method, who should I 
contact / where should I commit ?

First improvement and partial solution :

* returning a tuple of linecollections per "record", with its name and other 
properties.

Cheers,

Thomas

ps : example 
http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/

**
Thomas Lecocq

Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**

  --
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Daniel Fulger
Dear all,

contourset = pyplot.contour(..)

calculates the contourset but also grabs whatever figure is currently  
active *somewhere* in the entire code
and whichever scope it was created. The contours are plotted into it.

While I could possibly live with that, I would really like to
suppress any plotting and grabbig of focus. Only the contourset  
should be calculated.

I can't find anything that describes this. Everybody wants the plot,  
not me.

I would like to avoid hte workaround  to ask for the currently active  
figure (if!! there is one at all), store the number, and later return  
focus. Is there no switch parameter (in pyplot or for contour at  
least) that turns plotting off?

Regards
Daniel

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Paul Ivanov
Daniel Fulger, on 2011-01-27 18:16,  wrote:
> Dear all,
> 
> contourset = pyplot.contour(..)
> 
> calculates the contourset but also grabs whatever figure is currently  
> active *somewhere* in the entire code
> and whichever scope it was created. The contours are plotted into it.
> 
> While I could possibly live with that, I would really like to
> suppress any plotting and grabbig of focus. Only the contourset  
> should be calculated.
> 
> I can't find anything that describes this. Everybody wants the plot,  
> not me.
> 
> I would like to avoid hte workaround  to ask for the currently active  
> figure (if!! there is one at all), store the number, and later return  
> focus. Is there no switch parameter (in pyplot or for contour at  
> least) that turns plotting off?

Hi Daniel,

I'm not sure if this gets at what you're asking for, but if
you just want the contours plotted on a figure other than the
currently active one, grab a handle to some other axes and call
contour from the axes itself (the parameters are the same).
Here's what I mean:

---
f,ax  =plt.subplots(1,1) #grab handles to figure and axes
# or, if you're using an older version of matplotlib, do:
# f=plt.figure();ax=plt.subplot(1,1,1)


f2,ax2  =plt.subplots(1,1) # "f" no longer active figure
...
contourset = ax.contour(...) # draw to the old figure "f"
---

You can read more about the difference between using pyplot and
using the object-oriented api here:

http://matplotlib.sourceforge.net/faq/usage_faq.html

On the other hand, if you just want the contour to not show up,
you can pass it alpha=0.0 to make it completely transparent and
invisible (but it's still there)

contourset = pyplot.contour(.., alpha=0.0)
# later call contourset.set_alpha(1.0) to make visible again

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] too many values to unpack with a bar chart

2011-01-27 Thread C M
Hi Paul,

> The reason you were getting that error is because unless you
> specify otherwise, ax.bar will make the bottom of the bars at 0 -
> which isn't an allowed date, hence the error. Change your bar
> line to this (I also added align='center', but you can remove it
> if you want):

Aha, OK that makes sense.  Thank you.  I think the point #3 in my
previous email about the "Ordinal must be >= 1" has all been about
what is or isn't allowed as a proper date.

So your example worked of course, but I am still not able to get my
real code to plot a bar chart.  If I tell you what the format of the
data is, maybe you can help me.

I would like to plot dates (on x axis) versus time intervals (on y).
I have a list of dates and I have a two lists (self.data[0] and
self.data[1]), one of the start times ("bots") and one of the stop
times ("tops").  But when I go to plot it, and do this (based on your
code...for now leaving out the round() step):

 bots = self.data[0]
 tops = self.data[1]

bars = self.subplot.bar(self.final_dates, top-bot, bottom=bot, align='center')

I get the error:

TypeError: unsupported operand type(s) for -: 'list' and 'list'

Because I am trying to subtract the "bots" list from the "tops" list.
In the example code I gave, bot and times were not lists but were a
'numpy.ndarray' and a numpy.float64' object, respectfully, and I guess
the - operand can be used on them.

How can I structure my data such that this can work?  (For some reason
I have not had nearly this much confusion with plotting lines, just
bars).

Thanks for all the help,
Che (CM)

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Benjamin Root
On Thursday, January 27, 2011, Paul Ivanov  wrote:
> Daniel Fulger, on 2011-01-27 18:16,  wrote:
>> Dear all,
>>
>> contourset = pyplot.contour(..)
>>
>> calculates the contourset but also grabs whatever figure is currently
>> active *somewhere* in the entire code
>> and whichever scope it was created. The contours are plotted into it.
>>
>> While I could possibly live with that, I would really like to
>> suppress any plotting and grabbig of focus. Only the contourset
>> should be calculated.
>>
>> I can't find anything that describes this. Everybody wants the plot,
>> not me.
>>
>> I would like to avoid hte workaround  to ask for the currently active
>> figure (if!! there is one at all), store the number, and later return
>> focus. Is there no switch parameter (in pyplot or for contour at
>> least) that turns plotting off?
>
> Hi Daniel,
>
> I'm not sure if this gets at what you're asking for, but if
> you just want the contours plotted on a figure other than the
> currently active one, grab a handle to some other axes and call
> contour from the axes itself (the parameters are the same).
> Here's what I mean:
>
> ---
> f,ax  =plt.subplots(1,1) #grab handles to figure and axes
> # or, if you're using an older version of matplotlib, do:
> # f=plt.figure();ax=plt.subplot(1,1,1)
>
>
> f2,ax2  =plt.subplots(1,1) # "f" no longer active figure
> ...
> contourset = ax.contour(...) # draw to the old figure "f"
> ---
>
> You can read more about the difference between using pyplot and
> using the object-oriented api here:
>
> http://matplotlib.sourceforge.net/faq/usage_faq.html
>
> On the other hand, if you just want the contour to not show up,
> you can pass it alpha=0.0 to make it completely transparent and
> invisible (but it's still there)
>
> contourset = pyplot.contour(.., alpha=0.0)
> # later call contourset.set_alpha(1.0) to make visible again
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists,  off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>

I believe he would rather call the core function that contour uses to
do the heavy lifting.  This was something that one can do in matlab,
btw.  I don't have access to the source right now.  What does contour
call to perform this calculation?

Ben Root

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Daniel Fulger
>
> Dear all,
>
> contourset = pyplot.contour(..)
>
> calculates the contourset but also grabs whatever figure is currently
> active *somewhere* in the entire code
> and whichever scope it was created. The contours are plotted into it.
>
> While I could possibly live with that, I would really like to
> suppress any plotting and grabbig of focus. Only the contourset
> should be calculated.
>
> I can't find anything that describes this. Everybody wants the plot,
> not me.
>
> I would like to avoid hte workaround  to ask for the currently active
> figure (if!! there is one at all), store the number, and later return
> focus. Is there no switch parameter (in pyplot or for contour at
> least) that turns plotting off?
>
> Regards
> Daniel
>
>
>>
>> Hi Daniel,
>>
>> I'm not sure if this gets at what you're asking for, but if
>> you just want the contours plotted on a figure other than the
>> currently active one, grab a handle to some other axes and call
>> contour from the axes itself (the parameters are the same).
>> Here's what I mean:
>>
>> ---
>> f,ax  =plt.subplots(1,1) #grab handles to figure and axes
>> # or, if you're using an older version of matplotlib, do:
>> # f=plt.figure();ax=plt.subplot(1,1,1)
>>
>>
>> f2,ax2  =plt.subplots(1,1) # "f" no longer active figure
>> ...
>> contourset = ax.contour(...) # draw to the old figure "f"
>> ---
>>
>> You can read more about the difference between using pyplot and
>> using the object-oriented api here:
>>
>> http://matplotlib.sourceforge.net/faq/usage_faq.html
>>
>> On the other hand, if you just want the contour to not show up,
>> you can pass it alpha=0.0 to make it completely transparent and
>> invisible (but it's still there)
>>
>> contourset = pyplot.contour(.., alpha=0.0)
>> # later call contourset.set_alpha(1.0) to make visible again
>>
>> best,
>> --  
>> Paul Ivanov

Dear Paul,

no, I would like to suppress plotting entirely, avoid changing of  
active figure and avoid handling figures or axis completely.
I m only interested in the contourset. I wonder if my post was  
somehow sloppy.

Yes, there are work-arounds like creating a dummy figure, similar to  
your suggestion, and return focus to
the previously active figure. But plotting takes time and memory, is  
not needed and requires several code lines. Once might be ok but  
speed and memory is important.
Plotting with alpha=0 still requires figure and axis handling.

So how can I switch off all figure and axis related actions and  
savely call contourset = contour(x,y,...) that does nothing else than  
return the contours?


Regards
Daniel



--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] too many values to unpack with a bar chart

2011-01-27 Thread Paul Ivanov
C M, on 2011-01-27 13:56,  wrote:
> bars = self.subplot.bar(self.final_dates, top-bot, bottom=bot, align='center')
> 
> I get the error:
> 
> TypeError: unsupported operand type(s) for -: 'list' and 'list'
> 
> Because I am trying to subtract the "bots" list from the "tops" list.
> In the example code I gave, bot and times were not lists but were a
> 'numpy.ndarray' and a numpy.float64' object, respectfully, and I guess
> the - operand can be used on them.
> 
> How can I structure my data such that this can work?  (For some reason
> I have not had nearly this much confusion with plotting lines, just
> bars).

Che, 

just make a numpy array out of your two lists, and you'll be able
to subtract one from the other.

import numpy as np
top = np.array(top)
bot = np.array(bot)

best, 
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Eric Firing
On 01/27/2011 09:21 AM, Daniel Fulger wrote:
>>
>> Dear all,
>>
>> contourset = pyplot.contour(..)
>>
>> calculates the contourset but also grabs whatever figure is currently
>> active *somewhere* in the entire code
>> and whichever scope it was created. The contours are plotted into it.
>>
>> While I could possibly live with that, I would really like to
>> suppress any plotting and grabbig of focus. Only the contourset
>> should be calculated.
>>
>> I can't find anything that describes this. Everybody wants the plot,
>> not me.
>>
>> I would like to avoid hte workaround  to ask for the currently active
>> figure (if!! there is one at all), store the number, and later return
>> focus. Is there no switch parameter (in pyplot or for contour at
>> least) that turns plotting off?
>>
>> Regards
>> Daniel
>>
>>
>>>
>>> Hi Daniel,
>>>
>>> I'm not sure if this gets at what you're asking for, but if
>>> you just want the contours plotted on a figure other than the
>>> currently active one, grab a handle to some other axes and call
>>> contour from the axes itself (the parameters are the same).
>>> Here's what I mean:
>>>
>>> ---
>>> f,ax  =plt.subplots(1,1) #grab handles to figure and axes
>>> # or, if you're using an older version of matplotlib, do:
>>> # f=plt.figure();ax=plt.subplot(1,1,1)
>>>
>>>
>>> f2,ax2  =plt.subplots(1,1) # "f" no longer active figure
>>> ...
>>> contourset = ax.contour(...) # draw to the old figure "f"
>>> ---
>>>
>>> You can read more about the difference between using pyplot and
>>> using the object-oriented api here:
>>>
>>> http://matplotlib.sourceforge.net/faq/usage_faq.html
>>>
>>> On the other hand, if you just want the contour to not show up,
>>> you can pass it alpha=0.0 to make it completely transparent and
>>> invisible (but it's still there)
>>>
>>> contourset = pyplot.contour(.., alpha=0.0)
>>> # later call contourset.set_alpha(1.0) to make visible again
>>>
>>> best,
>>> --
>>> Paul Ivanov
>
> Dear Paul,
>
> no, I would like to suppress plotting entirely, avoid changing of
> active figure and avoid handling figures or axis completely.
> I m only interested in the contourset. I wonder if my post was
> somehow sloppy.
>
> Yes, there are work-arounds like creating a dummy figure, similar to
> your suggestion, and return focus to
> the previously active figure. But plotting takes time and memory, is
> not needed and requires several code lines. Once might be ok but
> speed and memory is important.
> Plotting with alpha=0 still requires figure and axis handling.
>
> So how can I switch off all figure and axis related actions and
> savely call contourset = contour(x,y,...) that does nothing else than
> return the contours?

Look at contour.py, specifically QuadCountourSet._process_args.  You 
will see the call to _cntr.Cntr.  That is the core class, implemented in 
extension code.  The contour generation is in the method 
_get_allsegs_and_allkinds, via the call to the Cntr.trace() method.  You 
will have to put together your own function to instantiate Cntr and call 
Cntr.trace for each level.

A major refactoring could be done to separate the calculation from the 
plotting, maybe by making the ContourSet into a compound artist and 
putting the drawing into a draw() method instead of having it called in 
the __init__() method.

Eric

>
>
> Regards
> Daniel
>

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Paul Ivanov
Benjamin Root, on 2011-01-27 13:04,  wrote:
> I believe he would rather call the core function that contour uses to
> do the heavy lifting.  This was something that one can do in matlab,
> btw.  I don't have access to the source right now.  What does contour
> call to perform this calculation?

matplotlib.contour.QuadContourSet - which in turn uses
ContourSet, and both take ax as a required argument. They use
matplotlib.contour._cntr  which is 


Daniel Fulger, on 2011-01-27 20:21,  wrote:
> no, I would like to suppress plotting entirely, avoid changing of  
> active figure and avoid handling figures or axis completely.
> I m only interested in the contourset. I wonder if my post was  
> somehow sloppy.
> 
> Yes, there are work-arounds like creating a dummy figure, similar to  
> your suggestion, and return focus to
> the previously active figure. But plotting takes time and memory, is  
> not needed and requires several code lines. Once might be ok but  
> speed and memory is important.
> Plotting with alpha=0 still requires figure and axis handling.
> 
> So how can I switch off all figure and axis related actions and  
> savely call contourset = contour(x,y,...) that does nothing else than  
> return the contours?

I understand better now, but as far as I could tell from poking
inside the QuadContourSet code, there isn't a simple way to
call the underlying machinery which generates the contours.

You'll have to look at what QuadContourSet._contour_args
does internally to see what what x, y, z should be, and then
create a contour using 

C = matplotlib.contour._cntr.Cntr(x,y,z) 

and then for each level, do something like what 
QuadContourSet._get_allsegs_and_allkinds does
C.trace(..) 

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 


signature.asc
Description: Digital signature
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pyplot: Extract contourset without plotting

2011-01-27 Thread Ian Thomas
Daniel,

Following on from Eric's comments, attached is the simplest example I could
come up with to do what you want.  For non-filled contours, the 'segs' (last
few lines of the file) should be fairly self-explanatory, and this is
hopefully what you want.  If you are after filled contours, you will need to
understand both the 'segs' and the 'kinds' - essentially the segs comprise
one or more discontinuous closed line loops and the corresponding kinds
indicate how the loops are split up, a 1 being a LINETO and a 2 being a
MOVETO.  This can get a little awkward, and I think that sometimes you need
to deal with arrays of arrays but I can't completely remember all the
details.

You should bear in mind that this code delves into matplotlib internals and
you need to be careful as
1) it bypasses various sanity checks,
2) the underlying code could change at any point in the future (it has quite
a lot in the last year for example).

Otherwise, I hope it helps!

Ian
import matplotlib._cntr as cntr
import numpy as np
import numpy.ma as ma


# Make your choice of filled contours or contour lines here.
wantFilledContours = True


# Test data.
x = np.arange(0, 10, 1)
y = np.arange(0, 10, 1)
x, y = np.meshgrid(x, y)
z = np.sin(x) + np.cos(y)

z = ma.asarray(z, dtype=np.float64)  # Import if want filled contours.

if wantFilledContours:
lower_level = 0.5
upper_level = 0.8
c = cntr.Cntr(x, y, z.filled())
nlist = c.trace(lower_level, upper_level, 0)
nseg = len(nlist)//2
segs = nlist[:nseg]
kinds = nlist[nseg:]
print segs# x,y coords of contour points.
print kinds   # kind codes: 1 = LINETO, 2 = MOVETO, etc.
  # See lib/matplotlib/path.py for details.
else:
# Non-filled contours (lines only).
level = 0.5
c = cntr.Cntr(x, y, z)
nlist = c.trace(level, level, 0)
segs = nlist[:len(nlist)//2]
print segs# x,y coords of contour points.
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] too many values to unpack with a bar chart

2011-01-27 Thread C M
> just make a numpy array out of your two lists, and you'll be able
> to subtract one from the other.
>
> import numpy as np
> top = np.array(top)
> bot = np.array(bot)

Thank you, Paul.  That worked and I'm now able to display bar charts.
I appreciate it.

Best,
Che

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] 3D Data to 2d Plots

2011-01-27 Thread Philipp A.
Hi list,
I want to visualize Plots over time.

This describes the data:
[image: 3dplot.png]

a) and b) are single scans, the cutting at the red bars is no problem.
c) illustrates how they are done over time.
d) is what I want. I think this
plotcould
be a starting point, but I don’t really understand what’s done there.
e) would be easier to do, like this
plot,
but information is lost this way (hidden behind higher values)

it would be best to do the following:
1. plot one horizontal line vertically above each other (gapless), one for
each scan (so the vertical axis is the time axis)
2. each line is displayed as a series of gradients directly next to to each
other (gapless)
3. the starting and ending point of each gradient are determined by the
horizontal position of two adjacent data points in the current scan
4. the colors of each gradient are determined by the vertical position of
the two adjacent data points in the current scan, relative to the total
maximum

has anyone an idea how to do this? i am really a matplotlib noob.
Philipp
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Extending readshapefile

2011-01-27 Thread Jeff Whitaker

On 1/27/11 6:35 AM, Thomas Lecocq wrote:

Hi all,

I would like to contribute to a better readshapefile method, who 
should I contact / where should I commit ?


First improvement and partial solution :

* returning a tuple of linecollections per "record", with its name and 
other properties.


Cheers,

Thomas

ps : example 
http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/


**
Thomas Lecocq
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**

Thomas:  If you could check out basemap from svn, add your changes, then 
create an svn diff, that would be ideal.  You either send the diff 
directly to me, or post it on the list.  Thanks.


-Jeff
--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 3D Data to 2d Plots

2011-01-27 Thread Mike Alger
Philip, 

 

A few questions before I give one possible solution, 

 

Does this plot need to be updated in real time ? or is this plot to be done in 
post processing?

 

if you can do the plots with post processing you should be able to use pcolor 
function to do your tasks 

http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html 

 

i won’t go into details but just assign:

 

X as 1d vector with your m/z values 

Y as 1d vector  your time values

And Z as a 2d array that will map counts/sec to both a “m/z” and “time” index

 

You will have to find the location for your other marks and then plot them on 
top of pcolor graph but that shouldn’t be too hard  just express your values (i 
am assuming 3dB cutoff points and peak power of some sort) in terms of X Y. I 
am almost certain there is probably a nice DSP way to solve for those X Y 
values once the data is in a 2d array but i am no expert on that mater. 

 

Good luck and hopefully this helps, 

 

Mike 

  

 

From: Philipp A. [mailto:[email protected]] 
Sent: January-27-11 5:15 PM
To: [email protected]
Subject: [Matplotlib-users] 3D Data to 2d Plots

 

Hi list,

I want to visualize Plots over time.

 

This describes the data:

 3dplot.png  

 

a) and b) are single scans, the cutting at the red bars is no problem.

c) illustrates how they are done over time.

d) is what I want. I think this plot 
  
could be a starting point, but I don’t really understand what’s done there.

e) would be easier to do, like this plot 
 , but 
information is lost this way (hidden behind higher values)

 

it would be best to do the following:

1. plot one horizontal line vertically above each other (gapless), one for each 
scan (so the vertical axis is the time axis)

2. each line is displayed as a series of gradients directly next to to each 
other (gapless)

3. the starting and ending point of each gradient are determined by the 
horizontal position of two adjacent data points in the current scan

4. the colors of each gradient are determined by the vertical position of the 
two adjacent data points in the current scan, relative to the total maximum

 

has anyone an idea how to do this? i am really a matplotlib noob.

Philipp

--
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users