Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49142c9

Browse files
FIX: Allow kwarg aliases in triplot
Co-authored-by: Elliott Sales de Andrade <[email protected]>
1 parent 7457cb7 commit 49142c9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/matplotlib/tests/test_triangulation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as plt
1010
import matplotlib.tri as mtri
1111
from matplotlib.path import Path
12-
from matplotlib.testing.decorators import image_comparison
12+
from matplotlib.testing.decorators import image_comparison, check_figures_equal
1313

1414

1515
def test_delaunay():
@@ -1177,3 +1177,12 @@ def test_tricontourset_reuse():
11771177
assert tcs2._contour_generator != tcs1._contour_generator
11781178
tcs3 = ax.tricontour(tcs1, z)
11791179
assert tcs3._contour_generator == tcs1._contour_generator
1180+
1181+
1182+
@check_figures_equal()
1183+
def test_triplot_with_ls(fig_test, fig_ref):
1184+
x = [0, 2, 1]
1185+
y = [0, 0, 1]
1186+
data = [[0, 1, 2]]
1187+
fig_test.subplots().triplot(x, y, data, ls='--')
1188+
fig_ref.subplots().triplot(x, y, data, linestyle='--')

lib/matplotlib/tri/triplot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import numpy as np
22
from matplotlib.tri.triangulation import Triangulation
3+
import matplotlib.cbook as cbook
4+
import matplotlib.lines as mlines
35

46

57
def triplot(ax, *args, **kwargs):
@@ -42,11 +44,11 @@ def triplot(ax, *args, **kwargs):
4244
linestyle, marker, color = matplotlib.axes._base._process_plot_format(fmt)
4345

4446
# Insert plot format string into a copy of kwargs (kwargs values prevail).
45-
kw = kwargs.copy()
47+
kw = cbook.normalize_kwargs(kwargs, mlines.Line2D)
4648
for key, val in zip(('linestyle', 'marker', 'color'),
4749
(linestyle, marker, color)):
4850
if val is not None:
49-
kw[key] = kwargs.get(key, val)
51+
kw.setdefault(key, val)
5052

5153
# Draw lines without markers.
5254
# Note 1: If we drew markers here, most markers would be drawn more than

0 commit comments

Comments
 (0)