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

Overhaul internals to remove "axis artist" usage and improve flexibility (new version 2.0!) #68

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
aa5c334
Add first playing around with moving things to SkyAxes.
erykoff Mar 30, 2024
2336305
Make more grid changes, working better.
erykoff Apr 4, 2024
a067d52
Refactor to bring more stuff into the new grid helper.
erykoff Apr 7, 2024
c048c6c
More refactoring.
erykoff Apr 7, 2024
42c02e4
More code removal and cleanup.
erykoff Apr 7, 2024
cfdde13
More refactoring, now with some lat labels close to the right place.
erykoff Apr 9, 2024
bcf12c7
Add more ticklabels and fix mollweide clipping.
erykoff Apr 10, 2024
5c800a3
Add label alignment overrides.
erykoff Apr 15, 2024
2b5cfee
Still debugging, but progress on spacings.
erykoff Sep 18, 2024
03323e8
Draw labels on top, but compute padding before.
erykoff Sep 18, 2024
0dbb822
Restore coordinate formatting on display.
erykoff Sep 18, 2024
2b832cf
Vendor in key parts of axisartist label code.
erykoff Sep 19, 2024
7e7d4ca
Simplify label calling.
erykoff Sep 19, 2024
bc44666
Fix axis label padding.
erykoff Sep 28, 2024
a0b9c40
Remove references to old axis artist code.
erykoff Oct 13, 2024
a21eaf6
Add docstrings to mpl_utils.
erykoff Oct 13, 2024
fad6013
Clean up skygrid code and add some docstrings.
erykoff Oct 13, 2024
b32c006
Clean up skyaxes and remove old calls.
erykoff Oct 13, 2024
2a9542b
Clean up formatting and imports.
erykoff Oct 13, 2024
a94827f
Add more docstrings.
erykoff Oct 13, 2024
f775f39
Fix alignment of equatorial labels.
erykoff Oct 14, 2024
eae60f2
Fix Mollweide visualization of the poles in full-sky projections.
erykoff Oct 14, 2024
b78357b
Add epsilon cushions to gridline intitialization.
erykoff Oct 15, 2024
325d8f2
Add support for drawing "inner" longitude labels for Albers.
erykoff Oct 15, 2024
1950ab2
Improve alignment of radial/inner longitude labels.
erykoff Oct 15, 2024
726cb0c
Add matplotlib license to mpl derived code.
erykoff Oct 15, 2024
a20a467
Remove unneeded vendored matplotlib code.
erykoff Oct 15, 2024
a53ab9e
Remove reference to vendored file.
erykoff Oct 15, 2024
de135a0
Do not import matplotlib.pyplot unless absolutely necessary.
erykoff Oct 15, 2024
bea2c8b
Replace do_celestial/do_gridlines with _celestial/_gridlines.
erykoff Oct 15, 2024
dba08d0
Add SkyAxes.tick_params() for much easier control of tick label param…
erykoff Oct 20, 2024
0afa4a5
Deprecate rcparams keyword as it is no longer needed.
erykoff Oct 20, 2024
19f2374
Add caching to SkyCRS transformer.
erykoff Oct 21, 2024
6ab6db8
Fix crash when redrawing with an inset colorbar.
erykoff Nov 13, 2024
37abbc9
Simplify transformation code for better caching.
erykoff Nov 16, 2024
b42ab8d
Remove unused imports.
erykoff Nov 16, 2024
d33a874
Fix use of default grid longitude/latitude lines.
erykoff Nov 16, 2024
63aa471
Fix call to old target_proj.
erykoff Nov 16, 2024
5e3c330
Use non-deprecated methods to set axis label sizes and line width.
erykoff Nov 16, 2024
c322511
Update comparison images for new plotting.
erykoff Nov 16, 2024
1fabbac
Update documentation images based on new version of code.
erykoff Nov 16, 2024
d095259
Add some color to the overrides.
erykoff Nov 16, 2024
bc77cd8
Add more color to the overrides.
erykoff Nov 16, 2024
e0f43cb
Update documentation on size overrides with new API.
erykoff Nov 16, 2024
f2e078f
Add functionality to allow lon_range/lat_range to set the extent prop…
erykoff Nov 20, 2024
8e6d1f6
Clarify use of zoom and lon_range/lat_range in docstrings.
erykoff Nov 20, 2024
5e7b708
Update build actions.
erykoff Nov 20, 2024
19c1a6b
Fix workflow actions.
erykoff Nov 20, 2024
a99a673
Try again.
erykoff Nov 20, 2024
70f6c51
Turn off all minor ticks.
erykoff Nov 20, 2024
fd46db1
Change crash to warning when trying to auto-zoom an empty map.
erykoff Dec 5, 2024
d4a0c46
Fix rounding error on tick labels.
erykoff Dec 5, 2024
8f108df
Refactor how gridlines are drawn to make them more flexible.
erykoff Dec 5, 2024
1aab9d8
Update legend to automatically put it on top, and add test for opaque…
erykoff Dec 5, 2024
365724a
Account for cos(lat) when computing ranges.
erykoff Dec 28, 2024
a4aff1c
Improve auto-longitude-range algorithm.
erykoff Dec 29, 2024
c881890
Update test image for improvements to auto-longitude-range algorithm.
erykoff Dec 29, 2024
fb5ec1b
Add tests for single-pixel maps (issue #64).
erykoff Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-package-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
miniforge-variant: Mambaforge
use-mamba: true

- name: Configure conda and install code
shell: bash -l {0}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-package-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge,defaults
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
miniforge-variant: Mambaforge
use-mamba: true

- name: Configure conda and install code
shell: bash -l {0}
Expand Down
34 changes: 21 additions & 13 deletions docs/basic_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ The default is to plot a thick line along the Galactic equator, and two dashed l
fig, ax = plt.subplots(figsize=(8, 5))
sp = skyproj.McBrydeSkyproj(ax=ax)
sp.draw_milky_way(label='Milky Way')
sp.legend()
sp.legend(loc="upper right")
plt.show()

.. image:: images/milky_way.png
Expand All @@ -148,7 +148,7 @@ When using :code:`draw_milky_way()`, it will plot in Galactic coordinates.
fig, ax = plt.subplots(figsize=(8, 5))
sp = skyproj.McBrydeSkyproj(ax=ax, galactic=True, longitude_ticks='symmetric')
sp.draw_milky_way(label='Milky Way')
sp.legend()
sp.legend(loc="upper right")
plt.show()

.. image:: images/milky_way_galactic.png
Expand Down Expand Up @@ -238,28 +238,36 @@ Plotting Customization

Much of the plotting functionality is decided by `SkyProj` itself.
However, there is a lot of customization available.
The fonts, font sizes, tick label sizes, etc, are all determined by the :code:`matplotlib` RC parameter dictionary.
A few of these in particular should be highlighted:
With `SkyProj` version 2 the customization is easier than ever.

Most fonts, font sizes, tick label sizes, etc, are set with the usual :code:`matplotlib` interface.
For example, you can set the tick label sizes and colors with :code:`sp.ax.tick_params(axis="x", labelsize=20, labelcolor="green")`.
The axis label sizes and colors can be set with :code:`sp.ax.set_xlabel("New X Label", fontsize=10, fontcolor="red")`.

Additional plot parameters are controlled via the :code:`matplotlib` RC parameter dictionary.
In particular:

* :code:`xticks.labelsize`: Sets the label size for the x (longitude) ticks on the plot.
* :code:`yticks.labelsize`: Sets the label size for the y (latitude) ticks on the plot.
* :code:`axes.linewidth`: Sets the width of the boundary of the full plot.
* :code:`axes.labelsize`: Sets the size of the x/y (lon/lat) labels; this will default to 16 unless specifically overridden with an :code:`rcparams`.

These values (and any others) can be overridden at the time of map instantiation with a temporary dictionary, like so:
To override values, we recommend using a matplotlib RC context, like the following.
Note that the internal use of the `rc_params` (from `SkyProj` version 1) has been deprecated and is no longer used.

.. code-block :: python

import matplotlib.pyplot as plt
import skyproj

# These values are comically exaggerated for effect.
rcparams = {'xtick.labelsize': 20,
'ytick.labelsize': 4,
'axes.linewidth': 5}
rcparams = {'axes.linewidth': 5}

with plt.rc_context(rcparams)
fig, ax = plt.subplots(figsize=(8, 5))
sp = skyproj.McBrydeSkyproj(ax=ax)

sp.ax.tick_params(axis="x", labelsize=20, labelcolor="green")
sp.ax.tick_params(axis="y", labelsize=4, labelcolor="blue")
sp.ax.set_xlabel("New X Label", fontsize=10, color="red")

fig, ax = plt.subplots(figsize=(8, 5))
sp = skyproj.McBrydeSkyproj(ax=ax, rcparams=rcparams)
plt.show()

.. image:: images/skyproj_full_override_sizes.png
Expand Down
Binary file modified docs/images/AlbersSkyproj_with_indicatrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/BLISS_survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/DECaLS_survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/DESAlbers_survey_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/DES_survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/DES_survey_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/EqualEarthSkyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/GnomonicSkyproj_with_indicatrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/HammerSkyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/LaeaSkyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/MagLiTeS_survey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/McBrydeSkyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/MollweideSkyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ObliqueMollweideSkyproj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/Skyproj_with_indicatrices.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/healsparse_one.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/healsparse_two.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/healsparse_valid_pixels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/hpxbin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/hpxbin_reproject.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/lines_and_polygons_0.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/milky_way.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/milky_way_galactic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/skyproj_full_override_sizes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ exclude = [
"docs/conf.py",
"docs/_build/html/conf.py",
"build",
"vendor/mpl_toolkit_functions.py",
]
1 change: 1 addition & 0 deletions skyproj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
from .transforms import *
from .skyaxes import *
from .survey import *
from .skygrid import *
17 changes: 11 additions & 6 deletions skyproj/_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def skyproj_init_parameters(intro_string, include_projection_name=False, include
Plotting in Galactic coordinates? Recommendation for Galactic plots
is to have longitude_ticks set to ``symmetric`` and celestial = True.
rcparams : `dict`, optional
Dictionary of matplotlib rc parameters to override. In particular, the code will
use ``xtick.labelsize`` and ``ytick.labelsize`` for the x and y tick labels, and
``axes.linewidth`` for the map boundary.
Deprecated; do not use. To set ``xtick.labelsize`` please use
``SkyProj.ax.tick_params()``. To set the map boundary width,
please set ``matplotlib.rcParams["axes.linewidth"]`` directly.
n_grid_lon : `int`, optional
Number of gridlines to use in the longitude direction
(default is axis_ratio * n_grid_lat).
Expand All @@ -67,7 +67,8 @@ def skyproj_init_parameters(intro_string, include_projection_name=False, include

draw_map_common_pars = """
zoom : `bool`, optional
Optimally zoom in projection to computed map.
Optimally zoom in projection to computed map. This will override
lon_range/lat_range if these are larger than the map.
xsize : `int`, optional
Number of rasterized pixels in the x direction.
vmin : `float`, optional
Expand All @@ -77,9 +78,13 @@ def skyproj_init_parameters(intro_string, include_projection_name=False, include
rasterized : `bool`, optional
Plot with rasterized graphics.
lon_range : `tuple` [`float`, `float`], optional
Longitude range to plot [``lon_min``, ``lon_max``].
Longitude range to plot [``lon_min``, ``lon_max``]. Map will
be truncated to this range prior to computing optimal zoom
(if zoom is ``True``).
lat_range : `tuple` [`float`, `float`], optional
Latitude range to plot [``lat_min``, ``lat_max``].
Latitude range to plot [``lat_min``, ``lat_max``]. Map will
be truncated to this range prior to computing optimal zoom
(if zoom is ``True``).
norm : `str` or `matplotlib.colors.Normalize`, optional
The normalization method used to scale the data. By default a
linear scaling is used. This may be an instance of `Normalize` or
Expand Down
Loading
Loading