marvin
marvin copied to clipboard
Multipanel plots with images don't work
Trying to put an image into the Multiplot example here: https://sdss-marvin.readthedocs.io/en/latest/tutorials/plotting-tutorial.html#multi-panel-map-plot-single-galaxy by swapping out one of the map commands with an image command
import matplotlib.pyplot as plt
import numpy as np
from marvin.tools import Maps
from marvin.tools.image import Image
maps = Maps('7977-12705')
halpha = maps.emline_gflux_ha_6564
nii_ha = np.log10(maps.emline_gflux_nii_6585 / halpha)
stvel = maps.stellar_vel
stsig = maps.stellar_sigma
stsig_corr = stsig.inst_sigma_correction()
image = Image(plateifu='7977-12705')
with plt.style.context('seaborn-darkgrid'):
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(12, 11))
halpha.plot(fig=fig, ax=axes[0, 0])
nii_ha.plot(fig=fig, ax=axes[0, 1], title="log([NII]6585 / H-alpha)", snr_min=None)
stvel.plot(fig=fig, ax=axes[1, 0])
#stsig_corr.plot(fig=fig, ax=axes[1, 1])
image.plot(fig=fig, ax=axes[1, 1])
Result does not put the image plot into the multipanel plot...?
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
Hi @karenlmasters the plot
method on Maps objects is a custom function that handles matplotlib
single panel or multi-panel plots. The Image.plot
is a separate standalone plot function that just returns a single matplotlib
figure. The ax=axes
input to Image.plot
isn't doing anything here. So I don't think what you want to do is possible out of the box. It's probably a good idea to make that work though.
You should be able to hack something together though, but you might need to use matplotlib
directly, and extract the image data and maps data from the Marvin objects. You can take a look at the Image.plot
code itself, https://github.com/sdss/marvin/blob/master/python/marvin/tools/image.py#L235-L275 itself. I know @KateRowlands needed to do something similar a while back, and may have some example code.