3 - Adding More Details to the Star Chart


Tutorial - Detailed Star Chart

Building on the first example, let's add some color and more objects to the plot, to create the chart above. Here's the revised code with the new lines highlighted:

from datetime import datetime
from pytz import timezone
from starplot import MapPlot, Projection
from starplot.styles import PlotStyle, extensions


tz = timezone("America/Los_Angeles")
dt = datetime(2023, 7, 13, 22, 0, tzinfo=tz)  # July 13, 2023 at 10pm PT

p = MapPlot(
    projection=Projection.ZENITH,
    lat=33.363484,
    lon=-116.836394,
    dt=dt,
    style=PlotStyle().extend(
        extensions.BLUE_MEDIUM,
    ),
    resolution=3600,
)
p.constellations()
p.stars(mag=4.6)

p.dsos(mag=9, true_size=True, labels=None)
p.constellation_borders()
p.ecliptic()
p.celestial_equator()
p.milky_way()

p.marker(
    ra=12.36,
    dec=25.85,
    label="Mel 111",
    style={
        "marker": {
            "size": 28,
            "symbol": "circle",
            "fill": "full",
            "color": "#ed7eed",
            "edge_color": "#e0c1e0",
            "alpha": 0.4,
        },
        "label": {
            "font_size": 12,
            "font_weight": "bold",
            "font_color": "#c83cc8",
            "font_alpha": 0.8,
        },
    },
)
p.horizon()

p.export("tutorial_03.png", transparent=True)

Here's an explanation of what we changed:

Line 15: Added the style keyword argument when creating the plot instance. This is an instance of a PlotStyle, and it represents ALL the styling properties to use for the plot (e.g. the colors, symbols, sizes, and more). In our revised example here, we create a default PlotStyle and then extend it with the BLUE_MEDIUM color scheme. Starplot has a very customizable styling framework that allows you to customize the appearance of just about anything you plot.

Line 23: Plot deep sky objects (DSOs) with a limiting magnitude of 9. The true_size=True argument tells Starplot to plot each DSO as their true apparent size in the sky. We also pass labels=None to hide all the labels for DSOs to avoid cluttering the plot.

Lines 24-27: Plot the constellation borders, ecliptic, celestial equator, and the Milky Way.

Lines 29-49: Add a marker for the Coma Star Cluster (aka Melotte 111), and customize its style. Starplot also has functions for plotting circles, rectangles, polygons, and more. See the reference for MapPlot for details.

In the next section, we'll learn how to create maps in other projections...