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

Skip to content

Commit b1812f7

Browse files
committed
tripcolor shading='faceted' deprecated in favour of edgecolors.
1 parent 7c7b037 commit b1812f7

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

lib/matplotlib/tri/tripcolor.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ def tripcolor(ax, *args, **kwargs):
3636
values are defined at points unless the kwarg *colorpoints* is
3737
set to *False*.
3838
39-
*shading* may be 'flat' (the default), 'faceted' or 'gouraud'. If
40-
*shading* is 'flat' or 'faceted' and C values are defined at
41-
points, the color values used for each triangle are from the mean
42-
C of the triangle's three points. If *shading* is 'gouraud' then
43-
color values must be defined at triangles.
39+
*shading* may be 'flat' (the default) or 'gouraud'. If *shading*
40+
is 'flat' and C values are defined at points, the color values
41+
used for each triangle are from the mean C of the triangle's
42+
three points. If *shading* is 'gouraud' then color values must be
43+
defined at triangles. *shading* of 'faceted' is deprecated;
44+
please use *edgecolors* instead.
4445
4546
The remaining kwargs are the same as for
4647
:meth:`~matplotlib.axes.Axes.pcolor`.
@@ -62,6 +63,28 @@ def tripcolor(ax, *args, **kwargs):
6263
tri, args, kwargs = Triangulation.get_from_args_and_kwargs(*args, **kwargs)
6364
C = np.asarray(args[0])
6465

66+
67+
# Handling of linewidths, shading, edgecolors and antialiased as
68+
# in Axes.pcolor
69+
linewidths = (0.25,)
70+
if 'linewidth' in kwargs:
71+
kwargs['linewidths'] = kwargs.pop('linewidth')
72+
kwargs.setdefault('linewidths', linewidths)
73+
74+
if shading == 'faceted': # Deprecated.
75+
edgecolors = 'k',
76+
else:
77+
edgecolors = 'none'
78+
if 'edgecolor' in kwargs:
79+
kwargs['edgecolors'] = kwargs.pop('edgecolor')
80+
ec = kwargs.setdefault('edgecolors', edgecolors)
81+
82+
if 'antialiased' in kwargs:
83+
kwargs['antialiaseds'] = kwargs.pop('antialiased')
84+
if 'antialiaseds' not in kwargs and ec.lower() == "none":
85+
kwargs['antialiaseds'] = False
86+
87+
6588
if shading == 'gouraud':
6689
if len(C) != len(tri.x):
6790
raise ValueError('For gouraud shading, the length of C '
@@ -79,16 +102,6 @@ def tripcolor(ax, *args, **kwargs):
79102
if len(C) == len(tri.x) and len(C) == len(tri.triangles):
80103
CAtPoints = colorpoints
81104

82-
if shading == 'faceted':
83-
edgecolors = (0,0,0,1),
84-
linewidths = (0.25,)
85-
else:
86-
edgecolors = 'face'
87-
linewidths = (1.0,)
88-
kwargs.setdefault('edgecolors', edgecolors)
89-
kwargs.setdefault('antialiaseds', (0,))
90-
kwargs.setdefault('linewidths', linewidths)
91-
92105
# Vertices of triangles.
93106
maskedTris = tri.get_masked_triangles()
94107
verts = np.concatenate((tri.x[maskedTris][...,np.newaxis],

0 commit comments

Comments
 (0)