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 73e2c0f

Browse filesBrowse files
committed
Correct contour level test
1 parent 8589672 commit 73e2c0f
Copy full SHA for 73e2c0f

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+10
-9
lines changed
Loading

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+10-9Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,22 @@ def test_given_colors_levels_and_extends():
168168
levels = [2, 4, 8, 10]
169169

170170
for i, ax in enumerate(axes.flatten()):
171-
plt.sca(ax)
172-
173171
filled = i % 2 == 0.
174172
extend = ['neither', 'min', 'max', 'both'][i // 2]
175173

176174
if filled:
177-
last_color = -1 if extend in ['min', 'max'] else None
178-
plt.contourf(data, colors=colors[:last_color], levels=levels,
179-
extend=extend)
175+
# If filled, we have 3 colors with no extension,
176+
# 4 colors with one extension, and 5 colors with both extensions
177+
first_color = 1 if extend in ['max', 'neither'] else None
178+
last_color = -1 if extend in ['min', 'neither'] else None
179+
c = ax.contourf(data, colors=colors[first_color:last_color],
180+
levels=levels, extend=extend)
180181
else:
181-
last_level = -1 if extend == 'both' else None
182-
plt.contour(data, colors=colors, levels=levels[:last_level],
183-
extend=extend)
182+
# If not filled, we have 4 levels and 4 colors
183+
c = ax.contour(data, colors=colors[:-1],
184+
levels=levels, extend=extend)
184185

185-
plt.colorbar()
186+
plt.colorbar(c, ax=ax)
186187

187188

188189
@image_comparison(baseline_images=['contour_datetime_axis'],

0 commit comments

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