1

I'm trying to plot a 2D FEM mesh in Python using Matlab code. I have my X,Y and color value arrays. Each of these arrays are in the shape of (Nodes per Element x Number of Total Elements). I tried to use pcolormesh but it doesn't produce the same result as patch function in Matlab.

What my plot looks like with the code axstress_xx.pcolormesh(X,Y,stress_xx,cmap='jet') in Python:

enter image description here

What it actually should look like with the code patch(app.postProcessGraph,X,Y,stress_xx,'FaceColor','interp','LineStyle',app.enableLine) in Matlab:

enter image description here

As you can see, the bottom left part of the plot doesn't seem to be right and also the plot seems not to have the right colors. I checked X,Y and color values both in Matlab and Python and they're totally the same. What am I missing here? Is pcolormesh different from patch function in terms of plotting mechanism?

  • Does this answer your question? [How can I plot 2d FEM results using matplotlib?](https://stackoverflow.com/questions/52202014/how-can-i-plot-2d-fem-results-using-matplotlib) – gboffi Jun 24 '20 at 06:47
  • Did you try `pcolormesh(...., shading='gouraud')`? – JohanC Jun 25 '20 at 10:55
  • By the way ["How Bad Is Your Colormap?"](https://jakevdp.github.io/blog/2014/10/16/how-bad-is-your-colormap/) explains why 'jet' isn't an ideal choice for this application. – JohanC Jun 25 '20 at 10:57

0 Answers0