""" /lectureNote/chapters/chapt05/codes/plot_flash_subplot.py An example Python subplotting code using a FLASH 2d data -- Sedov explosion on a uniform grid of size 256 x 256 See more examples and options at: http://matplotlib.org/gallery.html http://matplotlib.org/users/image_tutorial.html Written by Prof. Dongwook Lee, for AMS 209, Fall. """ import h5py import numpy as np import os import sys import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # ======================================= # 2D subplots maxDens = -1.0 minDens = 1.e10 for i in range(1,7,1): fileName = 'sedov_hdf5_chk_000'+str(i) file = h5py.File(fileName, 'r') var = file['dens'] if var[0,0,:,:].max() > maxDens: maxDens = var[0,0,:,:].max() if var[0,0,:,:].min() < minDens: minDens = var[0,0,:,:].min() fig,axes = plt.subplots(nrows=3,ncols=2) print (fig,axes) for i in range(1,7,1): print (i) fileName = 'sedov_hdf5_chk_000'+str(i) print (fileName) file = h5py.File(fileName, 'r') var = file['dens'] #plot_flash_2d_imshow(file) plt.subplot(3,2,i) plt.imshow(var[0,0,:,:],extent=[0,1,0,1],vmin=minDens,vmax=maxDens) plt.xlabel('$x$') plt.ylabel('$y$') #plt.title('2d plot of density') plt.colorbar() # ======================================= # Show plots to screen plt.show() # close file file.close()