@@ -278,9 +278,7 @@ def dovis(self, n):
278278
279279 elif (L_y > 2 * L_x ):
280280
281- # we want 4 columns:
282- #
283- # rho |U| p e
281+ # we want 4 columns: rho |U| p e
284282 fig , axes = pylab .subplots (nrows = 1 , ncols = 4 , num = 1 )
285283 if (L_y >= 3 * L_x ):
286284 shrink = 0.5
@@ -299,91 +297,41 @@ def dovis(self, n):
299297
300298 onLeft = [0 ,2 ]
301299
302- ax = axes .flat [0 ]
303300
304- img = ax .imshow (numpy .transpose (dens [myg .ilo :myg .ihi + 1 ,
305- myg .jlo :myg .jhi + 1 ]),
306- interpolation = "nearest" , origin = "lower" ,
307- extent = [myg .xmin , myg .xmax , myg .ymin , myg .ymax ])
308-
309- ax .set_xlabel ("x" )
310- ax .set_ylabel ("y" )
311- ax .set_title (r"$\rho$" )
312-
313- if not 0 in onLeft :
314- ax .yaxis .offsetText .set_visible (False )
315-
316- if sparseX :
317- ax .xaxis .set_major_locator (pylab .MaxNLocator (3 ))
318-
319- pylab .colorbar (img , ax = ax , orientation = orientation , shrink = shrink )
320-
321- ax = axes .flat [1 ]
322-
323- img = ax .imshow (numpy .transpose (magvel [myg .ilo :myg .ihi + 1 ,
324- myg .jlo :myg .jhi + 1 ]),
325- interpolation = "nearest" , origin = "lower" ,
326- extent = [myg .xmin , myg .xmax , myg .ymin , myg .ymax ])
327-
328- ax .set_xlabel ("x" )
329- if (allYlabel ): ax .set_ylabel ("y" )
330- ax .set_title ("U" )
331-
332- if not 1 in onLeft :
333- ax .get_yaxis ().set_visible (False )
334- ax .yaxis .offsetText .set_visible (False )
301+ fields = [dens , magvel , p , e ]
302+ field_names = [r"$\rho$" , r"U" , "p" , "e" ]
335303
336- if sparseX :
337- ax . xaxis . set_major_locator ( pylab . MaxNLocator ( 3 ))
304+ for n in range ( 4 ) :
305+ ax = axes . flat [ n ]
338306
339- pylab .colorbar (img , ax = ax , orientation = orientation , shrink = shrink )
340-
341- ax = axes .flat [2 ]
342-
343- img = ax .imshow (numpy .transpose (p [myg .ilo :myg .ihi + 1 ,
344- myg .jlo :myg .jhi + 1 ]),
307+ v = fields [n ]
308+ img = ax .imshow (numpy .transpose (v [myg .ilo :myg .ihi + 1 ,
309+ myg .jlo :myg .jhi + 1 ]),
345310 interpolation = "nearest" , origin = "lower" ,
346311 extent = [myg .xmin , myg .xmax , myg .ymin , myg .ymax ])
347312
348- ax .set_xlabel ("x" )
349- if (allYlabel ): ax .set_ylabel ("y" )
350- ax .set_title ("p" )
351-
352- if not 2 in onLeft :
353- ax .get_yaxis ().set_visible (False )
354- ax .yaxis .offsetText .set_visible (False )
355-
356- if sparseX :
357- ax .xaxis .set_major_locator (pylab .MaxNLocator (3 ))
358-
359- pylab .colorbar (img , ax = ax , orientation = orientation , shrink = shrink )
360-
361- ax = axes .flat [3 ]
313+ ax .set_xlabel ("x" )
314+ if n == 0 :
315+ ax .set_ylabel ("y" )
316+ elif allYlabel :
317+ ax .set_ylabel ("y" )
362318
363- img = ax .imshow (numpy .transpose (e [myg .ilo :myg .ihi + 1 ,
364- myg .jlo :myg .jhi + 1 ]),
365- interpolation = "nearest" , origin = "lower" ,
366- extent = [myg .xmin , myg .xmax , myg .ymin , myg .ymax ])
367-
368- ax .set_xlabel ("x" )
369- if (allYlabel ): ax .set_ylabel ("y" )
370- ax .set_title ("e" )
319+ ax .set_title (field_names [n ])
371320
372- if not 3 in onLeft :
373- ax .get_yaxis ().set_visible (False )
374- ax .yaxis .offsetText .set_visible (False )
321+ if not n in onLeft :
322+ ax .yaxis .offsetText .set_visible (False )
323+ if n > 0 : ax .get_yaxis ().set_visible (False )
324+
325+ if sparseX :
326+ ax .xaxis .set_major_locator (pylab .MaxNLocator (3 ))
375327
376- if sparseX :
377- ax .xaxis .set_major_locator (pylab .MaxNLocator (3 ))
328+ pylab .colorbar (img , ax = ax , orientation = orientation , shrink = shrink )
378329
379- pylab .colorbar (img , ax = ax , orientation = orientation , shrink = shrink )
380330
381331 pylab .figtext (0.05 ,0.0125 , "t = %10.5f" % self .cc_data .t )
382332
383333 pylab .draw ()
384334
385335
386336 def finalize (self ):
387-
388337 exec self .problem_name + '.finalize()'
389-
0 commit comments