Skip to content
This repository was archived by the owner on Jun 16, 2022. It is now read-only.

Commit 2da3825

Browse files
committed
Update the colorbar for the hard loading for the damage plots
1 parent 43be64b commit 2da3825

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

hard/plot-plate-hard-initial-crack.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
from matplotlib import rc
66
from matplotlib.colors import LinearSegmentedColormap
7+
import matplotlib as mpl
78

89
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
910
rc('text', usetex=True)
@@ -72,8 +73,8 @@ def grayscale_cmap(cmap):
7273
else:
7374
d_pos.append(nodes[i,0]+u_small[i][0])
7475

75-
print(max(d_pos))
76-
print(d_pos)
76+
#print(max(d_pos))
77+
#print(d_pos)
7778

7879
nodes_small = np.array(nodes_small)
7980
u_small = np.array(u_small)
@@ -85,7 +86,7 @@ def grayscale_cmap(cmap):
8586

8687

8788
ax = plt.gca()
88-
plt.scatter(nodes_small[:,0]+u_small[:,0],nodes_small[:,1]+u_small[:,1],c=u_small[:,1],cmap=grayscale_cmap("viridis"),marker="s",s=np.sqrt(30))
89+
plt.scatter(nodes_small[:,0]+u_small[:,0],nodes_small[:,1]+u_small[:,1],c=u_small[:,1],cmap=grayscale_cmap("viridis"),marker="s",s=np.sqrt(40))
8990
#ax.xaxis.tick_top()
9091
#ax.xaxis.set_label_position('top')
9192
fig = plt.gcf()
@@ -102,7 +103,14 @@ def grayscale_cmap(cmap):
102103
plt.clf()
103104

104105
#plt.figure(figsize=(20,1)) grayscale_cmap(plt.get_cmap("viridis"))
105-
plt.scatter(nodes_small[:,0],nodes_small[:,1],c=d_small,cmap=grayscale_cmap("viridis"),marker="s",s=np.sqrt(30))
106+
107+
#cmap = mpl.cm.coolwarm
108+
#bounds = [-1, 2, 5, 7, 12, 15]
109+
#bounds = [0,2.1e-1,8.2e-1,1.9,5.0,6.4]
110+
#norm = mpl.colors.BoundaryNorm(bounds, cmap.N, extend='both')
111+
112+
113+
plt.scatter(nodes_small[:,0],nodes_small[:,1],c=d_small,cmap="coolwarm",marker="s",s=np.sqrt(30),vmin=0,vmax=6.4)
106114
ax = plt.gca()
107115
#ax.xaxis.tick_top()
108116
#ax.xaxis.set_label_position('top')
@@ -112,10 +120,15 @@ def grayscale_cmap(cmap):
112120
plt.ylabel(r"Poistion $y$")
113121
#plt.ylim([-2,21])
114122
#plt.xlim([0,max(nodes[:,1])])
115-
v = np.linspace(min(d_small), max(d_small), 6, endpoint=True)
123+
#v = np.linspace(min(d_small), max(d_small), 6, endpoint=True)
124+
v = np.linspace(0, 6.4, 6, endpoint=True)
125+
#v = [0,2.1e-1,8.2e-1,1,1.9,5.0,6.4]
116126
clb = plt.colorbar(ticks=v,format='%.1e')
117127
clb.set_label(r'Damage')
118-
ax.hlines(y=7.5, xmin=0, xmax=7.5, linewidth=2, color='#FF7E00')
128+
#cmap = mpl.cm.coolwarm
129+
#norm = mpl.colors.Normalize(vmin=5, vmax=10)
130+
#fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap))
131+
ax.hlines(y=7.5, xmin=0, xmax=7.5, linewidth=2, color='black')
119132
plt.savefig("bond-based-2d-plate-"+str(h)+"-"+str(delta_factor)+"-"+str(iter)+"-d-rotated-hard.pdf",bbox_inches='tight')
120133

121134

0 commit comments

Comments
 (0)