Skip to content

Commit

Permalink
Update documentation on size overrides with new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Nov 16, 2024
1 parent bc77cd8 commit e0f43cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions docs/basic_interface.rst
Original file line number Diff line number Diff line change
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/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.

0 comments on commit e0f43cb

Please sign in to comment.