WCSAxes and shared axis
See original GitHub issueI am trying to plot a figure with several WCSAxes where I would like to have the sharex/sharey feature working. The basic example would be:
import numpy as np
from matplotlib import pyplot as plt
from astropy.io.fits import ImageHDU
from astropy.wcs import WCS
plt.ion()
# Same physical region on the sky
HDUs = []
for index in range(3):
npix = (index+1)*2+1
this_map = np.zeros((npix, npix))
this_map[1,1] = 1
w = WCS(naxis=2)
w.wcs.crpix = [(npix+1)/2, (npix+1)/2]
w.wcs.cdelt = [3./npix, 3./npix]
HDUs.append(ImageHDU(this_map, w.to_header()))
# Proper figure without shared axis
fig = plt.figure()
for index, hdu in enumerate(HDUs):
if index == 0:
ax_ref = fig.add_subplot(len(HDUs), 1, index+1,
projection=WCS(hdu.header))
ax_ref.imshow(hdu.data)
else:
ax = fig.add_subplot(len(HDUs), 1, index+1,
projection=WCS(hdu.header))
ax.imshow(hdu.data)
# Failing figure with shared axes
fig = plt.figure()
for index, hdu in enumerate(HDUs):
if index == 0:
ax_ref = fig.add_subplot(len(HDUs), 1, index+1,
projection=WCS(hdu.header))
ax_ref.imshow(hdu.data)
else:
ax = fig.add_subplot(len(HDUs), 1, index+1,
projection=WCS(hdu.header),
sharex=ax_ref, sharey=ax_ref)
ax.imshow(hdu.data)
But unfortunately it seems that the sharex sharey keyword only applied on the pixel scale. Is there a way to make it work on world coordinates ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
WCSAxes — Astropy v5.2
The main axes class that can be used to show world coordinates from a WCS. Parameters. fig Figure. The figure to add the...
Read more >WCSAxes — Astropy v2.0.dev18967 - Read the Docs
The main axes class that can be used to show world coordinates from a WCS. Parameters: fig : Figure. The figure to ...
Read more >Clearing a matplotlib axis labels, ticks and locators while ...
I wonder if anyone could please share any advice ... File "/anaconda3/lib/python3.8/site-packages/astropy/visualization/wcsaxes/core.py", ...
Read more >Source code for sunpy.visualization.wcsaxes_compat
WCSAxes ` The current axes, or a new one if created. ... the native coordinates to be bottom and left only so they...
Read more >Matplotlib — Visualization with Python
Join our community at discourse.matplotlib.org to get help, share your work, and discuss contributing & development. Check out the Matplotlib tag on ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No, it doesn’t. The axes are shared on a ‘pixel’ level, not a ‘world coordinate’ level. To fix this issue they would need to be shared on a ‘world coordinate’ level.
Would @dstansby 's code above resolve the original question? Can we close this issue? Thanks!