8000 Add test cases for patch.force_edgecolor behavior with facecolor="none" by Kaustbh · Pull Request #29690 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add test cases for patch.force_edgecolor behavior with facecolor="none" #29690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
10000
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,3 +1066,30 @@ def test_patch_hatchcolor_fallback_logic():
# hatch.color rcParam is set to 'edge' and edgecolor is not set
rect = Rectangle((0, 0), 1, 1, hatch='//')
assert mcolors.same_color(rect.get_hatchcolor(), mpl.rcParams['patch.edgecolor'])


def test_facecolor_none_force_edgecolor_false():
rcParams['patch.force_edgecolor'] = False # default value
rect = Rectangle((0, 0), 1, 1, facecolor="none")
assert rect.get_edgecolor() == (0.0, 0.0, 0.0, 0.0)


def test_facecolor_none_force_edgecolor_true():
rcParams['patch.force_edgecolor'] = True
rect = Rectangle((0, 0), 1, 1, facecolor="none")
assert rect.get_edgecolor() == (0.0, 0.0, 0.0, 1)


def test_facecolor_none_edgecolor_force_edgcolor():

# Case 1:force_edgecolor =False -> rcParams['patch.edgecolor'] should NOT be applied
rcParams['patch.force_edgecolor'] = False
rcParams['patch.edgecolor'] = 'red'
rect = Rectangle((0, 0), 1, 1, facecolor="none")
assert not mcolors.same_color(rect.get_edgecolor(), rcParams['patch.edgecolor'])

# Case 2:force_edgecolor =True -> rcParams['patch.edgecolor'] SHOULD be applied
rcParams['patch.force_edgecolor'] = True
rcParams['patch.edgecolor'] = 'red'
rect = Rectangle((0, 0), 1, 1, facecolor="none")
assert mcolors.same_color(rect.get_edgecolor(), rcParams['patch.edgecolor'])
Loading
0