Skip to content

Commit

Permalink
fix failing test because doctext expects nothing but mpl returns some…
Browse files Browse the repository at this point in the history
…thing
  • Loading branch information
henrysky committed Aug 23, 2024
1 parent 3ff862d commit 072502f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 15 deletions.
4 changes: 4 additions & 0 deletions docs/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ Useful constants
>>> from mw_plot import mw_radec # milkyway plane in RA/DEC
>>> center_radec # refers to the [RA, DEC] of galactic center in deg
[266.4167, -29.0078]
>>> anti_center_radec # refers to the [RA, DEC] of galactic anti-center in deg
[86.4167, 28.0078]
>>> northpole_radec # refers to the [RA, DEC] of galactic north pole in deg
[192.7667, 27.1167]
>>> southpole_radec # refers to the [RA, DEC] of galactic south pole in deg
[12.7667, -27.1167]
>>> mw_plane_ra, mw_plane_dec = mw_radec(deg=True) # RA/DEC arrays of milkyway plane
Expand Down
2 changes: 1 addition & 1 deletion docs/source/bokeh_single.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. automodule:: mw_plot.mw_plot_bokeh
.. automodule:: mw_plot.bokeh_backend

Interactive Single Plot
==========================
Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ For example, to get the citation text for the background image of a face-on Milk
>>> from mw_plot import MWFaceOn
>>> mw = MWFaceOn()
>>> mw.citation
'NASA/JPL-Caltech/R. Hurt (SSC/Caltech)'
or for the background infrared image of an all-sky Milky Way plot:

Expand All @@ -31,6 +32,7 @@ or for the background infrared image of an all-sky Milky Way plot:
>>> from mw_plot import MWSkyMap
>>> mw = MWSkyMap()
>>> mw.citation
'ESA/Gaia/DPAC'
Install
---------------------
Expand Down
6 changes: 5 additions & 1 deletion docs/source/matplotlib_faceon.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. automodule:: mw_plot.mw_plot_matplotlib
.. automodule:: mw_plot.matplotlib_backend

Face-On View of Milky Way
==============================
Expand Down Expand Up @@ -28,6 +28,10 @@ MilkyWay Bird's Eye
>>> mw1.title = "Bird's Eyes View"
>>> mw1.scatter(8 * u.kpc, 0 * u.kpc, c="r", s=2)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mw_faceon.jpg
:width: 500
:align: center
Expand Down
41 changes: 30 additions & 11 deletions docs/source/matplotlib_multi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ In a multiple subplot scenario, you can transform a single subplot with ``mw-plo
>>> mw1.transform(ax2)
>>> # plot something in the first subplot
>>> ax1.plot([0, 1], [0, 1])
>>> ax1.plot([0, 1], [1, 0])
>>> ax1.plot([0, 1], [0, 1]) # doctest:+ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
>>> ax1.plot([0, 1], [1, 0]) # doctest:+ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
>>> ax1.set_aspect("equal")
>>> # you can plot something on top of the transformed subplot
>>> ax2.plot([-10, 10], [10, -10], c="r", ls="--")
>>> ax2.plot([-10, 10], [10, -10], c="r", ls="--") # doctest:+ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mw_faceon_single_transform.jpg
:width: 500
Expand All @@ -43,13 +50,17 @@ To transform multiple subplots at once, you can pass a list of axes to the ``tra
>>> mw1 = MWFaceOn()
>>> fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
>>> # transform multiple axes with mw-plot at once
>>> mw1.transform([ax1, ax2])
>>> # plot something in both plots
>>> ax1.plot([10, -10], [10, -10], c="r", ls="--")
>>> ax2.plot([10, -10], [-10, 10], c="r", ls="--")
>>> ax1.plot([10, -10], [10, -10], c="r", ls="--") # doctest:+ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
>>> ax2.plot([10, -10], [-10, 10], c="r", ls="--") # doctest:+ELLIPSIS
[<matplotlib.lines.Line2D object at ...>]
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mw_faceon_multiple_transform.jpg
:width: 500
Expand Down Expand Up @@ -80,10 +91,18 @@ If you are plotting sky maps with projection, your subplot should be in that par
>>> mw4 = MWSkyMap(projection="mollweide", background="gamma")
>>> mw4.transform(ax4)
>>> ax1.set_title("Far-Infrared")
>>> ax2.set_title("Infrared")
>>> ax3.set_title("Optical")
>>> ax4.set_title("Gamma-Ray")
>>> ax1.set_title("Far-Infrared") # doctest:+ELLIPSIS
Text(...)
>>> ax2.set_title("Infrared") # doctest:+ELLIPSIS
Text(...)
>>> ax3.set_title("Optical") # doctest:+ELLIPSIS
Text(...)
>>> ax4.set_title("Gamma-Ray") # doctest:+ELLIPSIS
Text(...)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mollweide_4_backgrounds.jpg
:width: 500
Expand Down
18 changes: 17 additions & 1 deletion docs/source/matplotlib_skymap.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. automodule:: mw_plot.mw_plot_matplotlib
.. automodule:: mw_plot.matplotlib_backend

Sky Map of Milky Way
==============================
Expand All @@ -19,6 +19,10 @@ The class is designed to be simple and easy to use.
>>> mw1.title = "LMC and SMC in red dots"
>>> mw1.scatter([78.77, 16.26] * u.degree, [-69.01, -72.42] * u.degree, c="r", s=3)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mollweide_LMC_SMC.jpg
:width: 500
:align: center
Expand Down Expand Up @@ -58,6 +62,10 @@ You then can use the ``background`` parameter to set the background image from t
>>> mw1.title = "LMC and SMC in red dots"
>>> mw1.scatter([78.77, 16.26] * u.degree, [-69.01, -72.42] * u.degree, c="r", s=3)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mellinger_allsky.jpg
:width: 500
:align: center
Expand All @@ -78,6 +86,10 @@ parameters. For example to zoom in to the M31 galaxy, you can use the following
>>> fig, ax = plt.subplots(figsize=(5, 5))
>>> mw1.transform(ax)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mellinger_M31.jpg
:width: 500
:align: center
Expand All @@ -99,6 +111,10 @@ You can plot the sky map with grid lines. The grid lines can be in Galactic, Equ
>>> mw1.title = "LMC and SMC (red) with Ecliptic grid"
>>> mw1.scatter([78.77, 16.26] * u.degree, [-69.01, -72.42] * u.degree, c="r", s=3)
..
>>> import matplotlib.pyplot as plt
>>> plt.close("all")
.. image:: mpl_imgs/mellinger_allsky_grid.jpg
:width: 500
:align: center
Expand Down
Binary file added docs/source/mpl_imgs/mw_radec_constants.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/mw_plot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ def read_bg_img(self):
self.img_obj = self._MW_IMAGES["MW_bg_annotate"]
else:
self.img_obj = self._MW_IMAGES["MW_bg_unannotate"]
self.reference_str = self.img_obj.citation
self._gh_img_url = self._gh_imgbase_url + self.img_obj.filename

if self.coord.lower() == "galactic":
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_mw_skymap_bokeh(simbad):

def test_mw_plot_bokeh():
# setup a MWPlotBokeh instance
plot_instance = MWPlotBokeh(
plot_instance = MWFaceOnBokeh(
radius=20 * u.kpc, unit=u.kpc, coord="galactocentric", annotation=True
)
plot_instance.imalpha = 1.0
Expand Down

0 comments on commit 072502f

Please sign in to comment.