Skip to content
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

how to make a hips plot without the tile boundaries plotted #130

Closed
richardgmcmahon opened this issue Jul 21, 2018 · 5 comments
Closed

how to make a hips plot without the tile boundaries plotted #130

richardgmcmahon opened this issue Jul 21, 2018 · 5 comments
Labels
Milestone

Comments

@richardgmcmahon
Copy link

richardgmcmahon commented Jul 21, 2018

I am using the example plot_fits.py with a smaller fov:

https://github.com/hipspy/hips/blob/master/docs/getting_started.rst

width=360, height=360, fov="0.1 deg"

See attached png; How do I NOT get the tile boundaries plotted?

help(make_sky_image) does not tell me:

help(plot) tells me that the tiles arre are plotted but not how to NOT plot them
plot(self) -> None
| Plot the all sky image and overlay HiPS tile outlines.

result.plot()
# Draw the sky image
import matplotlib.pyplot as plt
from astropy.visualization.mpl_normalize import simple_norm
ax = plt.subplot(projection=geometry.wcs)
norm = simple_norm(result.image, 'sqrt', min_percent=1, max_percent=99)
ax.imshow(result.image, origin='lower', norm=norm, cmap='gray')

import matplotlib.pyplot as plt
plt.savefig('hips.png')
plt.show()

hips

If I do not call result.plot() before the plt sequence I get:

hips

So somewhere behind the scenes some matplotlib hidden magic is taking place. e.g. is make_sky_image doing some matplotlib work

As well as turning of the tile boundaries, it could be useful to know how to specify line color and line style for the tile boundaries too.

@adl1995
Copy link
Member

adl1995 commented Jul 23, 2018

Thanks for opening this issue.

The second image you draw using plt.show() actually does not plot the tile boundaries. The white lines you see at the tile edges are due to the tiles being summed twice on the all sky image (Cf. #79). We intend to replace this with a better drawing algorithm in the next release (v0.3).

I think it would be nice if the user could turn off the tile boundaries in result.plot() method, since we also provide the same functionality in plot_mpl_hips_tile_grid method. @cdeil - What do you think?

@cdeil cdeil added the question label Jul 23, 2018
@cdeil cdeil added this to the 0.3 milestone Jul 23, 2018
@cdeil
Copy link
Contributor

cdeil commented Jul 23, 2018

@adl1995 - If you want, you can add an option or two to the existing plot method, e.g. to turn the grid on or off.

But even more importantly, I think we have to make it clearer that this is just a little quicklook helper method, and point users to http://docs.astropy.org/en/stable/visualization/ to make nice plots, maybe showing an example or two (or showing the code for the existing example towards the end of that page).

I'm -1 to add options to control the grid - that grid is really only useful for us to debug the package. Maybe add an option show_grid that's False by default?

Basically we need to significantly update https://hips.readthedocs.io/en/latest/getting_started.html to explain better to people how to make nice, even publication quality plots; mostly point to http://docs.astropy.org/en/stable/visualization/, but do provide an example. Maybe move that to a second docs page plotting.rst?

@adl1995
Copy link
Member

adl1995 commented Jul 23, 2018

@cdeil - Would adding a section on "Plot using Astropy visualization toolkit" in the "Getting started" page be enough? We could redirect users to Astropy docs for further reading.

What sort of example should we provide using the astropy.visualization package? Currently, the example in the docs has this snippet:

from astropy.visualization.mpl_normalize import simple_norm
ax = plt.subplot(projection=geometry.wcs)
norm = simple_norm(result.image, 'sqrt', min_percent=1, max_percent=99)
ax.imshow(result.image, origin='lower', norm=norm, cmap='gray')

Which produces this plot:
astropy_plot

@cdeil
Copy link
Contributor

cdeil commented Jul 23, 2018

OK, if you want to keep the current single high-level docs page approach for now.

A key point to make is that usually grayscale / FITS images are plotted differently than RGB images.

For grayscale / FITS usually one will want to control the stretch, as you show in the example already.

For RGB, usually one will want to plot the pixels "as-is", without applying an extra stretch.
(although one could if desired)

In both cases, one can just save images / pixels as-is (mpl imsave), or plot using axes (mpl imshow / wcsaxes).

So really there's four cases / examples how to plot (float greyscale vs RGB input; and imsave vs imshow with MPL plotting).

Improving the docs on this plotting could go hand in hand with addressing #40, i.e. explaining what the output images contain.

(for RGB it's uint8 values in the range 0 to 255, plus in the case of PNG a transparency channel)

The documentation on this in this hips package can be short, linking to the astropy.visualisaiton or scikit-iamge docs where useful; but it really should be improved to make it clearer to users what they get out and how to work with it.

@cdeil
Copy link
Contributor

cdeil commented Jul 24, 2018

Done by @adl1995 in #131 .

@cdeil cdeil closed this as completed Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants