Constellation Labels not being inside the constellation boundaries
Sometimes, constellation labels will be awkwardly to a side (e.g. Hercules, Scutum, Corona Australis) and in some cases, just completely out of the boundary (e.g. Sagitta)
Also could there be labels for both Serpens (either duplicate Serpens labels or have one for Serpens cauda/caput)
image:
code:
from starplot import Star, DSO, MapPlot, Projection
from starplot.styles import PlotStyle, PolygonStyle, extensions
style = PlotStyle().extend(
extensions.BLUE_LIGHT,
extensions.MAP,
)
p = MapPlot(
projection=Projection.MILLER, # specify a non-perspective projection
ra_min=14, # limit the map to a specific area
ra_max=22,
dec_min=-45,
dec_max=65,
style=style,
resolution=4000,
hide_colliding_labels=False
)
p.gridlines() # add gridlines
p.stars(
where=[Star.magnitude < 6],
where_labels=[ (Star.magnitude < 3)],
bayer_labels=True
)
p.constellations()
p.constellation_borders()
p.milky_way()
p.celestial_equator()
p.ecliptic()
p.export("test.png", padding=0.2, transparent=True)
Environment Details:
- Starplot version: v0.11.4
- Python version: 3.11.8
- Matplotlib version: 3.9.2
This is a known issue with constellation labels, and something I'm continually trying to improve. This one is tough because it's difficult to come up with a good foolproof way to automatically determine the best positions for labels (which can also change depending on how many objects you plot, the styles, etc). It's easier to do this for points (e.g. stars) cause the label has a much smaller range where it makes sense.
In early versions of Starplot, I just put the constellation label at the centroid of the constellation lines, which works well for some constellations but not all.
Anyway, hopefully I stumble upon a good solution soon. Open to any and all ideas!
How are constellation name labels position determined currently?
currently, the constellation label positions are hard-coded here -- these positions were originally calculated by finding the centroid of each constellation (can't remember if I did it by stars, or boundary) and then manually fine-tuning a bunch of them where the centroid wasn't a good place to put the label. This actually works pretty well for zenith projections, but not great for others (as you've discovered).
@hemisemidemipresent not sure if you get notifications when issues are closed on GitHub, but wanted to let you know I added better "auto adjustment" handling for constellation labels in the latest version, 0.14 -- one important point though is that you have to plot constellation labels separately now, and ideally plot them last (so they can avoid collisions with stars you plotted). See the updated tutorial for an example.
Also, I would appreciate any feedback on the new algorithm -- in my testing so far, it seems pretty good, but it's still a little experimental and might need some tweaks.
yep I saw the new "auto adjustment" on the release page, will try it out