Skip to content

Labels off map when using CollisionHandler if where_labels=[True] #231

@enzodbspace

Description

@enzodbspace

Describe the bug
When using the demo CollisionHandler function and where_labels=[True], the image is generated much larger and the labels are outside the map area.

To Reproduce

from starplot import MapPlot, Stereographic, CollisionHandler, _
from starplot.styles import PlotStyle, extensions

# Create a custom collision handler that ensures labels are ALWAYS plotted
collision_handler = CollisionHandler(
	# always plot an object's label, even if it collides with other labels or markers:
	plot_on_fail=True,
	# only try plotting object labels once:
	attempts=1,
)

style = PlotStyle().extend(
	extensions.BLUE_LIGHT,
	extensions.MAP,
	{

	},
)

p = MapPlot(
	projection = Stereographic(center_ra= 9.5 * 15, center_dec= -45),
	ra_min = 7 * 15,
	ra_max = 10 * 15,
	dec_min = -70,
	dec_max = -20,
	style = style,
	resolution = 4000,
	scale = 1,
	hide_colliding_labels = False,
	autoscale = False,
	collision_handler=collision_handler,
)

p.constellations()

p.stars(
	where=[_.magnitude <= 7.5],
	where_labels=[False],
)

p.open_clusters(
	where_labels=[True],
)

p.constellation_labels()

p.export("labels-test-1.png", padding = 0, transparent=True)

Expected behavior
Labels printed only within the map area.

Screenshots
Image

Environment Details (please complete the following information):

  • Starplot version 0.19.6
  • Python version 3.14
  • Matplotlib version 3.10.8
  • OS: Windows 11 64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Work In ProgressbugSomething isn't working⭐ on roadmapThis issue is on the roadmap for a future version

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions