Skip to content

Fix marker fillstyle rotation transform#31301

Open
jayaprajapatii wants to merge 1 commit intomatplotlib:mainfrom
jayaprajapatii:fix-fillstyle-rotation
Open

Fix marker fillstyle rotation transform#31301
jayaprajapatii wants to merge 1 commit intomatplotlib:mainfrom
jayaprajapatii:fix-fillstyle-rotation

Conversation

@jayaprajapatii
Copy link
Contributor

@jayaprajapatii jayaprajapatii commented Mar 13, 2026

Closes #31257

Problem

Updating the fillstyle of a marker using Line2D.set_fillstyle() recreates the marker using MarkerStyle(self._marker.get_marker(), fs). This drops existing attributes stored in the original MarkerStyle, including the rotation transform. As a result, rotated markers lose their rotation after updating the fillstyle.

Cause

set_fillstyle() constructs a new MarkerStyle from the marker symbol. This discards internal attributes such as the transform that were present in the original MarkerStyle instance.

Solution

Use the MarkerStyle._with_attrs() factory method to construct the updated marker while preserving the attributes of the existing marker.
This ensures that properties such as transform, joinstyle, and capstyle remain unchanged when updating the fillstyle.

Changes

  • Updated Line2D.set_fillstyle() to use MarkerStyle._with_attrs() instead of constructing a new MarkerStyle.
  • Preserved marker attributes such as transform, joinstyle, capstyle and snap_threshold.
  • Added a regression test to ensure that rotated markers retain their transform when fillstyle is updated.

Result

Rotated markers now maintain their rotation when set_fillstyle() is called, matching the expected behaviour described in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Update of markers' fillstyle removes rotation transform

1 participant