hipspy / hips

Python library to handle HiPS
https://hips.readthedocs.io
12 stars 16 forks source link

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

Closed richardgmcmahon closed 5 years ago

richardgmcmahon commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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 https://github.com/hipspy/hips/issues/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 commented 5 years ago

Done by @adl1995 in #131 .