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 ee5d9c4

Browse filesBrowse files
authored
Merge pull request #22734 from andrew-fennell/tripcolor-clim-support
Added clim support to tripcolor
2 parents 91f3465 + 18ad350 commit ee5d9c4
Copy full SHA for ee5d9c4

File tree

Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed

‎lib/matplotlib/tests/test_triangulation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_triangulation.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ def test_tripcolor_color():
266266
ax.tripcolor(x, y, facecolors=[1, 2]) # faces
267267

268268

269+
def test_tripcolor_clim():
270+
np.random.seed(19680801)
271+
a, b, c = np.random.rand(10), np.random.rand(10), np.random.rand(10)
272+
273+
ax = plt.figure().add_subplot()
274+
clim = (0.25, 0.75)
275+
norm = ax.tripcolor(a, b, c, clim=clim).norm
276+
assert((norm.vmin, norm.vmax) == clim)
277+
278+
269279
def test_tripcolor_warnings():
270280
x = [-1, 0, 1, 0]
271281
y = [0, -1, 0, 1]

‎lib/matplotlib/tri/tripcolor.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tri/tripcolor.py
+5-9Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,14 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
115115
if 'antialiaseds' not in kwargs and ec.lower() == "none":
116116
kwargs['antialiaseds'] = False
117117

118+
_api.check_isinstance((Normalize, None), norm=norm)
118119
if shading == 'gouraud':
119120
if facecolors is not None:
120121
raise ValueError(
121122
"shading='gouraud' can only be used when the colors "
122123
"are specified at the points, not at the faces.")
123-
collection = TriMesh(tri, **kwargs)
124-
colors = point_colors
124+
collection = TriMesh(tri, alpha=alpha, array=point_colors,
125+
cmap=cmap, norm=norm, **kwargs)
125126
else:
126127
# Vertices of triangles.
127128
maskedTris = tri.get_masked_triangles()
@@ -136,14 +137,9 @@ def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None,
136137
colors = facecolors[~tri.mask]
137138
else:
138139
colors = facecolors
140+
collection = PolyCollection(verts, alpha=alpha, array=colors,
141+
cmap=cmap, norm=norm, **kwargs)
139142

140-
collection = PolyCollection(verts, **kwargs)
141-
142-
collection.set_alpha(alpha)
143-
collection.set_array(colors)
144-
_api.check_isinstance((Normalize, None), norm=norm)
145-
collection.set_cmap(cmap)
146-
collection.set_norm(norm)
147143
collection._scale_norm(norm, vmin, vmax)
148144
ax.grid(False)
149145

0 commit comments

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