-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sky region plot #221
base: main
Are you sure you want to change the base?
Sky region plot #221
Conversation
This sounds like it should be possible and I like the approach you've suggested for the skyregion plot api. The second issue, with the legend, sounds like a bug, and I don't understand it. |
@cdeil - if you are using WCSAxes, then |
@astrofrog - Thanks for the tip, implemented in 30eebc9 . If the current axis is a WCSAxes or one is passed in, calling plot on the sky region seems to work fine. I find this super convenient, it just does the right thing by default without having to pass the WCS all the time. @astrofrog @keflavich @sushobhana - Please review the API / implementation. Once it's clear what we want, I can add tests and docs. |
The approach you've taken looks fine, that's what I'd do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a plot
, there should be as_artist
method for sky regions?
In #76 (I think) I argued to remove the
contains
andplot
method onSkyRegion
objects, because it can be ambiguous how to transform the sky region to a pixel region and it's better to let the user be explicit:Now using it myself, and seeing others plot many regions in Gammapy, I find it annoying to have to do
sky_region.to_pix(wcs).plot(ax=ax)
all the time, and would prefersky_region.plot(ax=ax)
to work directly and do whatever DS9 does to plot, presumably already what ourto_pix(wcs).plot(ax=ax)
does.@astrofrog or anyone - is that possible? Does the
ax
have a link to thewcs
when using wcsaxes, so that we can add a one-lineer in a methodSkyRegion.plot
in the base class to make this work?Another issue I have with region plot is that if I call
PixRegion.plot
and thenplt.legend
, it never shows up in the legend. Only if I callregion.as_artist
andax.add_artist
does it show up in the legend. Does someone know if it's possible to plot regions and have them added to the legend in a simple way? Would be nice to extend the https://astropy-regions.readthedocs.io/en/latest/plotting.html page with an example.