Re: [Matplotlib-users] help plotting vector field in basemap

2013-04-08 Thread Eric Firing
On 2013/04/08 4:13 AM, epi wrote:
 Hi All,

 i'm new to basemap, truing to learn how to plot vector from a netcdf file

 the variables in my file are :

 - time
 - Significant_height_of_combined_wind_waves_and_swell_surface
 - u-component_of_wind_surface
 - v-component_of_wind_surface

 this is my code, the pcolormesh is fine

 

 import netCDF4
 import datetime as dt

 import numpy as np
 import numpy.ma as ma
 from datetime import date, datetime, timedelta

 from mpl_toolkits.basemap import Basemap



 url='http://geoport.whoi.edu/thredds/dodsC/fmrc/NCEP/ww3/cfsr/4m/best'
 #url = 'http://geoport.whoi.edu/thredds/dodsC/fmrc/NCEP/ww3/cfsr/10m/best'
 nc = netCDF4.Dataset(url)
 #nc.variables.keys()


 time_var = nc.variables[str('time')]
 wave_var = 
 nc.variables['Significant_height_of_combined_wind_waves_and_swell_surface']
 date = datetime(1991,11,1,12)
 istart = netCDF4.date2index(date,time_var,select='nearest')
 lat = nc.variables['lat'][:]
 lon = nc.variables['lon'][:]
 uin = nc.variables['u-component_of_wind_surface'][istart,:,:]
 vin = nc.variables['v-component_of_wind_surface'][istart,:,:]
 var = wave_var[istart,:,:]
 wave = ma.masked_where(np.isnan(var),var)


 m = Basemap(llcrnrlon=-71.5,llcrnrlat=39.5,urcrnrlon=-63.0,urcrnrlat=46.0,\
  lat_0=20.,lon_0=-60.,lat_ts=20.)


 lons, lats = np.meshgrid(lon,lat)
 x, y = m(lons, lats)


 m.pcolormesh(lon[:], lat[:], wave, vmin=0, vmax=3);
 m.quiver(x, y, uin, vin);

Try something like this:

m.quiver(x[::5,::5], y[::5,::5], uin[::5,::5], vin[::5,::5], scale=200);

You can use the scale and the scale_units kwargs to control the arrow 
lengths.  Quiver plots don't work visually when there are too many 
arrows, so given the scale of your plot, you need to subsample the wind 
vectors as illustrated.

Eric




 

 .. but the vector plot in overlay doesn't render what i'm looking for .. 
 obviously my fault in the code
 thank you for your precious help!


 --
 Minimize network downtime and maximize team effectiveness.
 Reduce network management and security costs.Learn how to hire
 the most talented Cisco Certified professionals. Visit the
 Employer Resources Portal
 http://www.cisco.com/web/learning/employer_resources/index.html
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] zig-zag to represent suppressed 0 on axis?

2013-04-08 Thread Kevin Hunter Kesling
At 4:20pm -0400 Sun, 07 Apr 2013, Francesco Montesano wrote:
 Il giorno 07/apr/2013 21:03, Kevin Hunter Kesling ha scritto:
 On the other hand, I'm still such a noob at Matplotlib ... is there
 a way to have one of the subplots take up more than its default 50%
 allotment?

 you can give a look at the last two plots in this example
 http://matplotlib.org/examples/pylab_examples/demo_tight_layout.html or use
 plot.axes providing the rectangle that you want

That is closer to what I want, but still not there.  I was finally able 
to find something that fit the bill to 95% of what I want:

http://matplotlib.1069221.n5.nabble.com/Proposal-for-Broken-Axes-td38050.html

The first post by 'klukas' does exactly what I asked for.  It's a 
zig-zag on the Y-axis to show that what is graphed is not continuous, 
and unlike the various official examples, the zig-zag placement is 
user-specifiable, as opposed to exactly halfway between the top and bottom.

The only thing I have yet to figure out how to do is to simultaneously 
have a zig-zag on the X axis as well -- an artifact of how these 
zig-zags must be created via multiple axes on the same figure, rather 
than as built in to the axis artist.

For googleability:

The above linked graph code enables for matplotlib:

  - suppressed zeros on the Y-axis of an XY plot
  - showing suppressed data on the Y-axis
  - lightning bolt symbol on the Y-axis
  - zig-zag on the Y-axis
  - a broken Y-axis

Thanks for your pointers, Francesco, as they helped me to fine-tune my 
Google search terms.  And thank you, Klukas, whoever you are.

Cheers,

Kevin

--
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] zig-zag to represent suppressed 0 on axis?

2013-04-08 Thread ChaoYue
Hi Kevin,

I don't check the link you provided very carefully. So I guess you already
find a solution.
otherwise I have done something similar before and have made a bit general
function to do
the job, which I think might be helpful for you.

You can check the following three functions at
https://github.com/ChaoYue/pylsce/blob/master/g.py

Calc_Newaxes_Fraction
Axes_Replace_Split_Axes
Axes_Set_Breakaxis

a working example is below:

 fig,axs = plt.subplots(nrows=2)
 bottom_ax, top_ax =
g.Axes_Replace_Split_Axes(fig,axs[0],split_fraction=[0.36,0.04,0.6],direction='v')
 g.Axes_Set_Breakaxis(bottom_ax, top_ax, 0.01,0.03,'v')
 left_ax, right_ax =
g.Axes_Replace_Split_Axes(fig,axs[1],split_fraction=[0.38,0.02,0.6],direction='h')
 g.Axes_Set_Breakaxis(left_ax, right_ax, 0.03,0.02,'h')

the figure is as attached.

cheers,

chao



On Mon, Apr 8, 2013 at 9:05 PM, Kevin Hunter [via matplotlib] 
ml-node+s1069221n40857...@n5.nabble.com wrote:

 At 4:20pm -0400 Sun, 07 Apr 2013, Francesco Montesano wrote:
  Il giorno 07/apr/2013 21:03, Kevin Hunter Kesling ha scritto:
  On the other hand, I'm still such a noob at Matplotlib ... is there
  a way to have one of the subplots take up more than its default 50%
  allotment?
 
  you can give a look at the last two plots in this example
  http://matplotlib.org/examples/pylab_examples/demo_tight_layout.html or
 use
  plot.axes providing the rectangle that you want

 That is closer to what I want, but still not there.  I was finally able
 to find something that fit the bill to 95% of what I want:


 http://matplotlib.1069221.n5.nabble.com/Proposal-for-Broken-Axes-td38050.html

 The first post by 'klukas' does exactly what I asked for.  It's a
 zig-zag on the Y-axis to show that what is graphed is not continuous,
 and unlike the various official examples, the zig-zag placement is
 user-specifiable, as opposed to exactly halfway between the top and
 bottom.

 The only thing I have yet to figure out how to do is to simultaneously
 have a zig-zag on the X axis as well -- an artifact of how these
 zig-zags must be created via multiple axes on the same figure, rather
 than as built in to the axis artist.

 For googleability:

 The above linked graph code enables for matplotlib:

   - suppressed zeros on the Y-axis of an XY plot
   - showing suppressed data on the Y-axis
   - lightning bolt symbol on the Y-axis
   - zig-zag on the Y-axis
   - a broken Y-axis

 Thanks for your pointers, Francesco, as they helped me to fine-tune my
 Google search terms.  And thank you, Klukas, whoever you are.

 Cheers,

 Kevin

 --

 Minimize network downtime and maximize team effectiveness.
 Reduce network management and security costs.Learn how to hire
 the most talented Cisco Certified professionals. Visit the
 Employer Resources Portal
 http://www.cisco.com/web/learning/employer_resources/index.html
 ___
 Matplotlib-users mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=40857i=0
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://matplotlib.1069221.n5.nabble.com/zig-zag-to-represent-suppressed-0-on-axis-tp40849p40857.html
  To start a new topic under matplotlib - users, email
 ml-node+s1069221n...@n5.nabble.com
 To unsubscribe from matplotlib, click 
 herehttp://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx
 .
 NAMLhttp://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml




-- 
***
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16



break_axis.jpg (182K) 
http://matplotlib.1069221.n5.nabble.com/attachment/40858/0/break_axis.jpg




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/zig-zag-to-represent-suppressed-0-on-axis-tp40849p40858.html
Sent from the matplotlib - users mailing list archive at Nabble.com.--
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal

Re: [Matplotlib-users] zig-zag to represent suppressed 0 on axis?

2013-04-08 Thread Francesco Montesano
Il giorno 08/apr/2013 21:05, Kevin Hunter Kesling kmhun...@ncsu.edu ha
scritto:

 At 4:20pm -0400 Sun, 07 Apr 2013, Francesco Montesano wrote:

 Il giorno 07/apr/2013 21:03, Kevin Hunter Kesling ha scritto:

 On the other hand, I'm still such a noob at Matplotlib ... is there
 a way to have one of the subplots take up more than its default 50%
 allotment?


 you can give a look at the last two plots in this example
 http://matplotlib.org/examples/pylab_examples/demo_tight_layout.html or
use
 plot.axes providing the rectangle that you want


 That is closer to what I want, but still not there.  I was finally able
to find something that fit the bill to 95% of what I want:


http://matplotlib.1069221.n5.nabble.com/Proposal-for-Broken-Axes-td38050.html

 The first post by 'klukas' does exactly what I asked for.  It's a zig-zag
on the Y-axis to show that what is graphed is not continuous, and unlike
the various official examples, the zig-zag placement is user-specifiable,
as opposed to exactly halfway between the top and bottom.

 The only thing I have yet to figure out how to do is to simultaneously
have a zig-zag on the X axis as well -- an artifact of how these zig-zags
must be created via multiple axes on the same figure, rather than as built
in to the axis artist.

 For googleability:

 The above linked graph code enables for matplotlib:

  - suppressed zeros on the Y-axis of an XY plot
  - showing suppressed data on the Y-axis
  - lightning bolt symbol on the Y-axis
  - zig-zag on the Y-axis
  - a broken Y-axis

 Thanks for your pointers, Francesco, as they helped me to fine-tune my
Google search terms.  And thank you, Klukas, whoever you are.


I'm half that you found the solution for your problem and to have been
useful just providing links. This has been one of the easiest answer I have
ever given :)

And mostly thanks for sharing your findings.

cheers and good night,
Fra

 Cheers,

 Kevin
--
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] verts

2013-04-08 Thread Steven Boada
Hey List,

I've got some verts I stole from the internet that draws an upward arrow 
(or a down arrow), but I need to draw an arrow to the right or to the 
left. But I don't really understand verts and how they work.

arrowup_verts = [[0.,0.], [-1., -1], [0.,0.], [0.,-2.],[0.,0.], [1,-1]]
arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.], [0.,2.],[0.,0.], [1, 1]]

plot them like...

scatter(1,1,s=100, marker=None, verts=arrowup_verts)


Can someone make me new verts for the right and left arrow? Then, maybe 
tomorrow, explain how I was supposed to know what to do.

Thanks y'all

Steven

-- 

Steven Boada

Doctoral Student
Dept of Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu


--
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis  visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] verts

2013-04-08 Thread Steven Boada
Thanks Zach,

That simple little example makes more sense than the manual page did. 
Perhaps it's just late.

I appreciate it.

Steven

On Mon Apr  8 22:30:43 2013, Zachary Pincus wrote:
 I've got some verts I stole from the internet that draws an upward arrow
 (or a down arrow), but I need to draw an arrow to the right or to the
 left. But I don't really understand verts and how they work.

 arrowup_verts = [[0.,0.], [-1., -1], [0.,0.], [0.,-2.],[0.,0.], [1,-1]]
 arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.], [0.,2.],[0.,0.], [1, 1]]

 plot them like...

 scatter(1,1,s=100, marker=None, verts=arrowup_verts)


 Can someone make me new verts for the right and left arrow? Then, maybe
 tomorrow, explain how I was supposed to know what to do.

 Draw a line from (0,0) to (-1, -1) on the X-Y plane, and then to (0,0) again, 
 and then continue so forth for all the (x,y) pairs in arrowup_verts. You will 
 notice they form a nice little arrow pointing up. (At some point in this 
 process, you should note that verts is short for vertices. As in vertices 
 of a polygon or poly-line.)

 It would seem that the origin of the verts coordinate system is translated 
 to the (x,y) data position at which each marker is plotted.

 This should give you, I presume, sufficient information to figure out your 
 own left and right arrows, no? Or any other shape you should care to plot...

 Zach


 Thanks y'all

 Steven

 --

 Steven Boada

 Doctoral Student
 Dept of Physics and Astronomy
 Texas AM University
 bo...@physics.tamu.edu


 --
 Precog is a next-generation analytics platform capable of advanced
 analytics on semi-structured data. The platform includes APIs for building
 apps and a phenomenal toolset for data science. Developers can use
 our toolset for easy data analysis  visualization. Get a free account!
 http://www2.precog.com/precogplatform/slashdotnewsletter
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--

Steven Boada

Doctoral Student
Dept of Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu

--
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis  visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users