Home > Mobile >  How to plot 2 maps in 1 plot using Matplotlib? (Python)
How to plot 2 maps in 1 plot using Matplotlib? (Python)

Time:08-06

I was trying to overlay 1 map on another, but I could not.

input_file = "slicedSmoothedStokesPlanck/Smoothed_Sliced_PSI_MAP.fits"
i_file = "slicedSmoothedStokesPlanck/Smoothed_Sliced_I_MAP.fits"
pl_b = fits.getdata(input_file, ext=0)
i_file_data = fits.getdata(i_file, ext=0)

fig = plt.figure()
ax = fig.add_subplot(111) #, projection=wcs
im = ax.imshow(texture, alpha=0.5) #, cmap='RdYlBu_r'
ax.imshow(i_file_data)
plt.title("TEST")
plt.show()

The above code, only shows last ax.imshow(i_file_data)

The idea is that I have a map1, and map2. I want to overlay map2 with alpha = 0.5 on map1, and plot it.

CodePudding user response:

There's an example in the matplotlib documentation similar to your case: https://matplotlib.org/stable/gallery/images_contours_and_fields/layer_images.html#sphx-glr-gallery-images-contours-and-fields-layer-images-py

  • Related