# Plot Fill with Jacobian Coordinates

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

···

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@…287…> 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

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.

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

···

On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@…287…> 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

Hello,

I tried using contour and now I have a figure!

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:

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

···

On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@…287…> wrote:

On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@…287…> 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.

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

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

···

On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith <yeoman.python@…287…> wrote:

On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@…1972…> wrote:

On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@…287…> 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.

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!

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:

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

Ben,

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

The script used to produce figure2 is here:

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

···

On Thu, Dec 15, 2011 at 9:32 PM, Benjamin Root <ben.root@…1304…> wrote:

On Thu, Dec 15, 2011 at 3:18 PM, Alex Naysmith <yeoman.python@…287…> wrote:

On Tue, Dec 13, 2011 at 7:12 PM, Alex Naysmith <yeoman.python@…287…> wrote:

On Mon, Dec 12, 2011 at 7:03 PM, Benjamin Root <ben.root@…1304…> wrote:

On Sat, Dec 10, 2011 at 10:36 AM, Alex Naysmith <yeoman.python@…287…> 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.

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!

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:

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