37
37
38
38
def plot_voxels_3D (data , Ngr = 1 , sliced = False , dual_phase = False ,
39
39
mask = None , cmap = 'prism' , alpha = 1.0 , silent = False ,
40
- clist = None ):
40
+ clist = None , asp_arr = None ):
41
41
"""
42
42
Plot voxels in microstructure, each grain with a different color. Sliced
43
43
indicates whether one eighth of the box should be removed to see internal
@@ -75,7 +75,8 @@ def plot_voxels_3D(data, Ngr=1, sliced=False, dual_phase=False,
75
75
Nx = data .shape [0 ]
76
76
Ny = data .shape [1 ]
77
77
Nz = data .shape [2 ]
78
-
78
+ if asp_arr is None :
79
+ asp_arr = [1 , 1 , 1 ]
79
80
if mask is None :
80
81
vox_b = np .full (data .shape , True , dtype = bool )
81
82
else :
@@ -116,14 +117,15 @@ def plot_voxels_3D(data, Ngr=1, sliced=False, dual_phase=False,
116
117
ax .set_xlim (right = Nx )
117
118
ax .set_ylim (top = Ny )
118
119
ax .set_zlim (top = Nz )
120
+ ax .set_box_aspect (asp_arr )
119
121
if silent :
120
122
return fig
121
123
else :
122
124
plt .show (block = True )
123
125
124
126
125
127
def plot_polygons_3D (geometry , cmap = 'prism' , alpha = 0.4 , ec = [0.5 , 0.5 , 0.5 , 0.1 ],
126
- dual_phase = False , silent = False ):
128
+ dual_phase = False , silent = False , asp_arr = None ):
127
129
"""
128
130
Plot triangularized convex hulls of grains, based on vertices, i.e.
129
131
connection points of 4 up to 8 grains or the end points of triple or quadruple
@@ -148,6 +150,8 @@ def plot_polygons_3D(geometry, cmap='prism', alpha=0.4, ec=[0.5, 0.5, 0.5, 0.1],
148
150
None.
149
151
150
152
"""
153
+ if asp_arr is None :
154
+ asp_arr = [1 , 1 , 1 ]
151
155
grains = geometry ['Grains' ]
152
156
pts = geometry ['Points' ]
153
157
Ng = np .amax (list (grains .keys ()))
@@ -171,14 +175,15 @@ def plot_polygons_3D(geometry, cmap='prism', alpha=0.4, ec=[0.5, 0.5, 0.5, 0.1],
171
175
ax .set (xlabel = 'x' , ylabel = 'y' , zlabel = 'z' )
172
176
ax .set_title ('Polygonized microstructure' )
173
177
ax .view_init (30 , 30 )
178
+ ax .set_box_aspect (asp_arr )
174
179
if silent :
175
180
return fig
176
181
else :
177
182
plt .show (block = True )
178
183
179
184
180
185
181
- def plot_ellipsoids_3D (particles , cmap = 'prism' , dual_phase = False , silent = False ):
186
+ def plot_ellipsoids_3D (particles , cmap = 'prism' , dual_phase = False , silent = False , asp_arr = None ):
182
187
"""
183
188
Display ellipsoids after packing procedure
184
189
Parameters
@@ -190,7 +195,8 @@ def plot_ellipsoids_3D(particles, cmap='prism', dual_phase=False, silent=False):
190
195
dual_phase : bool, optional
191
196
Whether to display the ellipsoids in red/green contrast or in colors
192
197
"""
193
-
198
+ if asp_arr is None :
199
+ asp_arr = [1 , 1 , 1 ]
194
200
fig = plt .figure (figsize = (6 , 6 ))
195
201
ax = fig .add_subplot (111 , projection = '3d' )
196
202
ax .set (xlabel = 'x' , ylabel = 'y' , zlabel = 'z' )
@@ -211,14 +217,16 @@ def plot_ellipsoids_3D(particles, cmap='prism', dual_phase=False, silent=False):
211
217
y = (pts [:, 1 ] + ctr [1 ]).reshape ((100 , 100 ))
212
218
z = (pts [:, 2 ] + ctr [2 ]).reshape ((100 , 100 ))
213
219
ax .plot_surface (x , y , z , rstride = 4 , cstride = 4 , color = color , linewidth = 0 , antialiased = False )
220
+ ax .set_box_aspect (asp_arr )
214
221
if silent :
215
222
return fig
216
223
else :
217
224
plt .show (block = True )
218
225
219
226
220
227
221
- def plot_particles_3D (particles , cmap = 'prism' , dual_phase = False , plot_hull = True , silent = False ):
228
+ def plot_particles_3D (particles , cmap = 'prism' , dual_phase = False , plot_hull = True ,
229
+ silent = False , asp_arr = None ):
222
230
"""
223
231
Display inner polyhedra of ellipsoids after packing procedure
224
232
@@ -238,6 +246,8 @@ def plot_particles_3D(particles, cmap='prism', dual_phase=False, plot_hull=True,
238
246
None.
239
247
240
248
"""
249
+ if asp_arr is None :
250
+ asp_arr = [1 , 1 , 1 ]
241
251
fig = plt .figure (figsize = plt .figaspect (1 ))
242
252
ax = fig .add_subplot (111 , projection = '3d' )
243
253
ax .set (xlabel = 'x' , ylabel = 'y' , zlabel = 'z' )
@@ -272,6 +282,7 @@ def plot_particles_3D(particles, cmap='prism', dual_phase=False, plot_hull=True,
272
282
y = (pts [:, 1 ] + ctr [None , 1 ]).reshape ((100 , 100 ))
273
283
z = (pts [:, 2 ] + ctr [None , 2 ]).reshape ((100 , 100 ))
274
284
ax .plot_surface (x , y , z , rstride = 4 , cstride = 4 , color = col , linewidth = 0 )
285
+ ax .set_box_aspect (asp_arr )
275
286
if silent :
276
287
return fig
277
288
else :
0 commit comments