Skip to content

Back to Examples

Galaxy Plot

map-galaxy

from starplot import GalaxyPlot, DSO, _
from starplot.styles import PlotStyle, extensions


style = PlotStyle().extend(
    extensions.BLUE_NIGHT,
    extensions.MAP,
    {
        "figure": {
            "padding": 60,
        }
    },
)

p = GalaxyPlot(style=style)

p.gridlines()
p.galactic_equator(num_labels=2)
p.celestial_equator(num_labels=2)
p.ecliptic(num_labels=2)

p.milky_way()

p.stars(
    where=[_.magnitude < 6],
    where_labels=[False],
    style__marker__stroke="#c5c5c5",
)

lmc = DSO.get(name="ESO056-115")
smc = DSO.get(name="NGC0292")
mc_style = {
    "fill": "#acc2e0",
    "font_size": 42,
    "font_weight": 700,
    "stroke_width": 8,
    "stroke": "#1e232a",
}

p.text(
    "LMC",
    ra=lmc.ra,
    dec=lmc.dec,
    style=mc_style,
)

p.text(
    "SMC",
    ra=smc.ra,
    dec=smc.dec,
    style=mc_style,
)

p.open_clusters(
    where=[(_.magnitude < 16) | (_.magnitude.isnull())],
    where_labels=[False],
    where_true_size=[False],
)
p.legend()

p.title("Open Clusters Around the Milky Way", style__font_size=86)

p.export("map_galaxy.png")