I try to plot stress of beam by using matplotlib library.
I have calculated by using formulas and plot it for an example:
As Figure 1, you will see that the green beam has more stress at element 3 and also element 8 Thus if i fill the color by rainbow gradient,The over all of blue beam will be same color but The green beam will have different color by the element 3 and 8 will be going to red side more than others.
Here is some of my code and result.
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
node_coordinate = {1: [0.0, 1.0], 2: [0.0, 0.0], 3: [4.018905, 0.87781],
4: [3.978008, -0.1229], 5: [1.983549, -0.038322],
6: [2.013683, 0.958586], 7: [3.018193, 0.922264],
8: [2.979695, -0.079299], 9: [1.0070439, 0.989987],
10: [0.9909098, -0.014787999999999999]}
element_stress = {1: 0.2572e+01, 2: 0.8214e+00, 3: 0.5689e+01,
4: -0.8214e+00, 5: -0.2572e+01, 6: -0.4292e+01,
7: 0.4292e+01, 8: -0.5689e+01}
n = len(element_stress.keys())
x = np.empty(n)
y = np.empty(n)
d = np.empty(n)
for i in element_stress.keys():
x[i-1] = node_coordinate[i][0]
y[i-1] = node_coordinate[i][1]
d[i-1] = element_stress[i]
mask = np.logical_or(x < 1.e20, y < 1.e20)
x = np.compress(mask, x)
y = np.compress(mask, y)
triang = tri.Triangulation(x, y)
cmap = mpl.cm.jet
fig = plt.figure(figsize=(80, 40))
ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
cax = ax1.tricontourf(triang, d, cmap=cmap)
fig.colorbar(cax)
plt.show()
You will see that i know all of node co-ordinate and also element's stress value.
But the color of my figure is not smooth and not arrange in horizontal as the example figure above.
How to do as same as it?
p.s. Sorry for my grammar, I'm not native.
Thank you. For suggestion.


