Re: [Matplotlib-users] Plot Fill with Jacobian Coordinates

2011-12-18 Thread Alex Naysmith
On Thu, Dec 15, 2011 at 9:32 PM, Benjamin Root ben.r...@ou.edu wrote:


 On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith yeoman.pyt...@gmail.comwrote:



 On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith 
 yeoman.pyt...@gmail.comwrote:



 On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root ben.r...@ou.edu wrote:

 On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith 
 yeoman.pyt...@gmail.com wrote:

 Hello,

 I'm trying to plot the stresses in colour of a strained isoparametric
 element.

 I have a six noded triangle with vertice coordinates
 [(xa1,ya1),(xa2,ya2),(xa3,ya3)] = pos_a

 This triangle deforms and the new coordinate positions are
 [(xb1,yb1),(xa2,yb2),(xb3,yb3)] = pos_b

 The remaining nodes are mid nodes also with rest and deformed
 coordinate positions.

 To plot the edges of the triangle I use a Jacobian transformation
 function so that the coordinates of the triangle are in Jacobian
 coordinates xi1 and xi2 (with xi3 = 1 - xi1 - xi2). This is required as 
 the
 elements are quadratic with mid-nodes.

 Each interval is hard coded so that:
 xi1 = [1.0,0.9,0.8,0.7,0.6,0.5, etc..]
 xi2 = [0.0,0.1,0.2,0.3,0.4,0.5, etc..]

 I would like to plot the strains in colour so that the interior of the
 triangle is filled but I don't want to hard code the Jacobian intervals as
 this seems an awkward way of doing it.

 With strain as a function of xi1 and xi2, How can matplotlib provide a
 continuous interior strain plot of the triangle for all the xi1 and xi2
 values from 0 to 1?

 Regards

 Alex Naysmith


 Alex,

 Perhaps if you can provide an example figure, we might be able to
 better help you.  Right now, I am having trouble envisioning what you
 describe.

 Ben Root

 Ben,

 I have created a script that uses one isoparametric triangle as an
 example. The triangle nodes undergo a displacement, resulting in strains
 inside the triangle. The new script calculates the strains inside the
 triangle for a range of xi1 and xi2 barycentric coordinates and returns the
 global coordinates with the corresponding strain.

 I would like matplotlib to give me a nice interpolated colour plot of
 the strains inside the triangle, but as the output global coordinates are
 not aligned in neat rows and columns, I cannot do a straightforward
 meshgrid plot with imshow.

 http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/files

 There are further comments in the script that may explain things better.

 I want a figure like this:

 http://matplotlib.sourceforge.net/examples/pylab_examples/animation_demo.html
 But for a 6 noded quadratic triangle instead of square. The intention is
 to have all the triangles in the mesh display their strains with
 interpolated colours.

 Regards

 Alex


 Hello,

 I tried using contour and now I have a figure!


 http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure.png

 I can now show clearly what I'm aiming for with this figure. I want the
 contour fill to remain inside the triangle. There will be a whole mesh of
 triangles to fill.

 The updated sample script is here:


 http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v2.py

 I arranged my data points into square X and Y arrays along with the
 strains in the Z array and then simply P.contourf(X, Y, Z)

 As the figure shows, it's not there yet as a couple of the corners aren't
 filled in and there's a big fill outside the triangle. I think this is due
 to difficulties in translating points from the natural triangle coordinates
 (barycentric) to the x,y coordinates. But the contour looks correct as it's
 interpolated between the strain points.

 Regards

 Alex


 Alex,

 Just curious, have you checked to see if tricontourf() meets your needs?


 http://matplotlib.sourceforge.net/api/axes_api.html?highlight=tricontourf#matplotlib.axes.Axes.tricontourf

 Ben Root

 Ben,

I've now succeeded in producing the plot I want using just contour(X,Y,Z):

http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/figure2.png

The script used to produce figure2 is here:

http://bazaar.launchpad.net/~eckeroo/misc/mpl_scripts/view/head:/triangle_fill_v3.py

For the X,Y and Z arrays, the upper triangle repeats the same data point.
This doesn't seem to be a problem for the contour(X,Y,Z) function.

The tricontourf() approach may be better, but it involves creating a
triangle mesh inside each element.

The next step will be to plot the strain contours for all the elements in
the mesh.

Regards

Alex Naysmith
--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure___
Matplotlib-users mailing list

[Matplotlib-users] Remapping scattered data

2011-12-18 Thread Alexis Praga
Hi,

I may have found an issue with some map projections.When I try to plot
markers on a given map, and change the center ofprojection, the
markers' coordinates are not remapped correctly.If the marker's
coordinates are not inside the new boundaries, it issimply not
displayed in some cases.For example, remapping does work with Robin's
projection and does notwith Miller's.I have attached a small example.
Thanks !


Alexis Praga
import numpy as np
import sys 
import matplotlib.pyplot as p
from mpl_toolkits.basemap import Basemap

nb_lat = 2
nb_lon = 360
nb_lines = nb_lat*nb_lon
lat = np.zeros(nb_lines,float)
lon = np.zeros(nb_lines,float)
data = np.zeros(nb_lines,float)
k = 0
for i in range(nb_lat):
  for j in range(nb_lon):
lat[k] = i
lon[k] = j-180
data[k] = i+j
k = k + 1

## This works
#map = Basemap(projection='robin',lon_0=180,resolution='c')
# Not this
map = Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,llcrnrlon=0,urcrnrlon=360,resolution='c')
map.drawcoastlines()
map.drawmapboundary()

x,y = map(lon,lat)
map.scatter(x,y, s=10, c=data, marker='o',edgecolors='none')

p.savefig('dataset.jpg')
--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Remapping scattered data

2011-12-18 Thread Alexis Praga
Exactly. But I do not understand why some map projectionsautomatically
adjust the data and others don't.

Alexis
On Sun, Dec 18, 2011 at 3:53 PM, Jeff Whitaker jsw...@fastmail.fm wrote:
 On 12/18/11 1:33 PM, Alexis Praga wrote:

 Hi,

 I may have found an issue with some map projections.When I try to plot
 markers on a given map, and change the center ofprojection, the
 markers' coordinates are not remapped correctly.If the marker's
 coordinates are not inside the new boundaries, it issimply not
 displayed in some cases.For example, remapping does work with Robin's
 projection and does notwith Miller's.I have attached a small example.
 Thanks !


 Alexis Praga

 Alexis: It looks like the coordinates you are plotting with scatter are
 between longitudes -180 and 180, and the map projection goes from 0 to 360.
  Adjust your coordinates to lie within 0 and 360, and they will show up.

 This behavior will be map projection dependent - it will only show up in the
 cylindrical projections where the x coordinate is longitude.

 -Jeff



--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Remapping scattered data

2011-12-18 Thread Jeff Whitaker
On 12/18/11 1:33 PM, Alexis Praga wrote:
 Hi,

 I may have found an issue with some map projections.When I try to plot
 markers on a given map, and change the center ofprojection, the
 markers' coordinates are not remapped correctly.If the marker's
 coordinates are not inside the new boundaries, it issimply not
 displayed in some cases.For example, remapping does work with Robin's
 projection and does notwith Miller's.I have attached a small example.
 Thanks !


 Alexis Praga

Alexis: It looks like the coordinates you are plotting with scatter are 
between longitudes -180 and 180, and the map projection goes from 0 to 
360.  Adjust your coordinates to lie within 0 and 360, and they will 
show up.

This behavior will be map projection dependent - it will only show up in 
the cylindrical projections where the x coordinate is longitude.

-Jeff



--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Strange time series plotting behavior / bug

2011-12-18 Thread Eric Firing
On 12/18/2011 01:13 PM, Wes McKinney wrote:
 This is a new one on me and extremely distressing:

 If I plot 139 dates versus 139 values, everything is OK

 In [40]: stamp = datetime.today()

 In [44]: from datetime import timedelta

 In [45]: inc = timedelta(1)

 In [46]: stamps = [stamp + inc * i for i in xrange(139)]

 In [47]: values = np.random.randn(139)

 In [48]: plt.plot(stamps, values)
 Out[48]: [matplotlib.lines.Line2D at 0x6ed0e50]

 See plot 1 attached

 However, if I increase it to 140 (!), all hell breaks loose:

 In [49]: stamps = [stamp + inc * i for i in xrange(140)]

 In [50]: values = np.random.randn(140)

 In [51]: plt.plot(stamps, values)
 Out[51]: [matplotlib.lines.Line2D at 0x73a21d0]

 see plot 2

 It seems to get ahold of itself at 153 dates (but not 152!). I tested
 this both with git master and v1.1.0. I don't even know what to say.

Confirmed. The AutoDateLocator is using an RRuleLocator which is 
cranking out a tick for every day.  I suspect the problem is in 
AutoDateLocator.get_locator(); it is not finding what it is looking for, 
so it is falling back on a default.  I can't look into it any time soon, 
so I hope someone else can; I'm not familiar with this code.

Eric


 thanks,
 Wes

--
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users