1

I have a code that can create three individual figures corresponding to xy, xz, and yz projections of a 3d function by running the following line on ipython3 interactive shell (after importing some required modules called gizmo and utilities):

gizmo.analysis.Image.plot_image(part, 'dark', 'mass', 'histogram', [i,j],[0,1,2], 300, 0.5, use_column_units=None)

where [i,j]=[0,1] would successfully create xy map, [i,j]=[0,2] would create xz map and [i,j]=[1,2] would create yz map separately.

But, I would like to merge all three maps into one figure using a single python script: (something like this)

import matplotlib.pyplot as plt
from matplotlib import gridspec
import gizmo
import utilities as ut


part=gizmo.io.Read.read_snapshots('all', 'redshift', 0, element_indices=None)

plt.figure()

plt.subplot(2,1,1)
gizmo.analysis.Image.plot_image(part, 'dark', 'mass', 'histogram', [0,1],[0,1,2], 300, 0.5, use_column_units=None)

plt.subplot(2,2,1)
gizmo.analysis.Image.plot_image(part, 'dark', 'mass', 'histogram', [0,2],[0,1,2], 300, 0.5, use_column_units=None)

plt.subplot(2,2,2)
gizmo.analysis.Image.plot_image(part, 'dark', 'mass', 'histogram', [1,2],[0,1,2], 300, 0.5, use_column_units=None)


plt.tight_layout()
plt.savefig('myfigure.png', dpi=900)
plt.show()

I did some search in the web and I arrived at this example How to combine several matplotlib figures into one figure? which is not helpful given the fact that I already have the individual png plots already. Your help is greatly appreciated,

Community
  • 1
  • 1
Rebel
  • 472
  • 8
  • 25

0 Answers0