Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e13ee8d

Browse filesBrowse files
committed
Change error message and add a test for it
1 parent 7c5d798 commit e13ee8d
Copy full SHA for e13ee8d

File tree

Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def draw(self, renderer):
617617
elif self.shadow is False:
618618
pass
619619
else:
620-
raise ValueError('shadow must be a valid color or bool')
620+
raise ValueError('Shadow must be a valid color or bool.')
621621

622622
self.legendPatch.draw(renderer)
623623
self._legend_box.draw(renderer)

‎lib/matplotlib/tests/test_legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_legend.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,21 @@ def test_shadow_color():
526526
plt.gca().add_artist(legends[x])
527527

528528

529+
def test_shadow_bad_type():
530+
# Ensure an error is thrown if the value of shadow
531+
# is neither colorlike nor bool
532+
# fig, ax = plt.subplots()
533+
# ax.plot(range(100), label="test")
534+
# with pytest.raises(ValueError, match='valid color or bool') as e:
535+
# ax.legend(shadow='Aardvark')
536+
537+
fig, ax = plt.subplots()
538+
ax.plot(range(100), label="test")
539+
with pytest.raises(ValueError, match="color or bool"):
540+
x = plt.legend(loc="upper left", shadow="aardvark")
541+
fig.canvas.draw()
542+
543+
529544
def test_legend_title_empty():
530545
# test that if we don't set the legend title, that
531546
# it comes back as an empty string, and that it is not

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.