Single Plot
Classes API
- class mw_plot.MWPlot(mode='face-on', center=<Quantity [0., 0.] kpc>, radius=<Quantity 90750. lyr>, unit=Unit("kpc"), coord='galactic', annotation=True, rot90=0, grayscale=False, r0=8.125, figsize=(7.5, 7.5), dpi=None)[source]
MWPlot class plotting with Matplotlib
- Parameters:
mode (str, either 'face-on' or 'edge-on') – whether plot edge-on or face-on milkyway
center (astropy.Quantity) – Coordinates of the center of the plot with astropy units
radius (astropy.Quantity) – Radius of the plot with astropy units
unit (astropy.Quantity) – astropy units
coord (str) – ‘galactocentric’ or ‘galactic’
annotation (bool) – whether use a milkyway background with annotation
rot90 (int) – number of 90 degree rotation
grayscale (bool) – whether to use grayscale background
r0 (float) – distance to galactic center in kpc
figsize (turple) – Matplotlib figure size
dpi (int) – Matplotlib figure dpi
- annotate(*args, **kwargs)[source]
Plot annotation
- History:
2022-Jan-02 - Written - Henry Leung (University of Toronto)
- initialize_mwplot(fig=None, ax=None)[source]
Internal method to initial mw_plot images and plot
- Returns:
None
- scatter_annotate(text, position, arrowprops={'facecolor': 'black', 'headlength': 6.0, 'headwidth': 6.0, 'width': 1.0}, fontsize=15, bbox={'pad': 2}, **kwargs)[source]
Plot annotation with scatter
- History:
2022-Jan-02 - Written - Henry Leung (University of Toronto)
- class mw_plot.MWSkyMap(projection='equirectangular', center=<Quantity [0., 0.] deg>, radius=<Quantity [180., 90.] deg>, grayscale=False, figsize=(10, 6.5), dpi=None)[source]
MWSkyMap class plotting with Matplotlib
- Parameters:
projection (string(["equirectangular", "aitoff", "hammer", "lambert", "mollweide"])) – projection system of the plot
center (astropy.Quantity) – Coordinates of the center of the plot with astropy degree/radian units
radius (astropy.Quantity) – Radius of the plot with astropy degree/radian units
grayscale (bool) – whether to use grayscale background
figsize (turple) – Matplotlib figure size
dpi (int) – Matplotlib figure dpi
- annotate(*args, **kwargs)[source]
Plot annotation
- History:
2022-Jan-02 - Written - Henry Leung (University of Toronto)
MilkyWay Bird’s Eye
1import numpy as np
2from astropy import units as u
3from mw_plot import MWPlot
4
5# setup a mw-plot instance of bird's eye view of the disc
6mw1 = MWPlot(radius=20 * u.kpc, unit=u.kpc, coord='galactocentric', annotation=True, figsize=(15, 12))
7
8# set up plot title
9mw1.title = "Bird's Eyes View"
10
11mw1.scatter(8*u.kpc, 0*u.kpc, c='r', s=200)
Annotation
1import numpy as np
2from astropy import units as u
3from mw_plot import MWPlot
4
5mw1 = MWPlot(radius=20 * u.kpc, unit=u.kpc, coord="galactocentric", annotation=True)
6
7# set up plot title
8mw1.title = "Annotation"
9
10mw1.scatter_annotate(["Earth", "Galactic \n Center"], [[8., 0.], [0., 0.]] * u.kpc)
MilkyWay Sky Map
1import numpy as np
2from astropy import units as u
3from mw_plot import MWSkyMap
4
5# setup a MWSkyMap instance with projection, other projection can be 'hammer', 'mollweide' etc
6# grayscale: whether to turn the background image to grayscale
7mw1 = MWSkyMap(projection='aitoff', grayscale=False)
8
9# set up plot title
10mw1.title = 'LMC and SMC in red dots'
11
12# LMC and SMC coordinates
13lsmc_ra = [78.77, 16.26] * u.degree
14lsmc_dec = [-69.01, -72.42] * u.degree
15
16mw1.scatter(lsmc_ra, lsmc_dec, c='r', s=200)