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

Skip to content

Commit 3c01e5b

Browse files
committed
Added to test_contour.py for colorbar behavior
Two image check tests were added to test_contour.py to make a contourf plot using input argument vmax, one with vmax greater than the maximum of the data set z values and one with vmax less than the maximum of the data set z values.
1 parent f627dc7 commit 3c01e5b

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

17.3 KB
Loading
19.2 KB
Loading

lib/matplotlib/tests/test_contour.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@ def test_given_colors_levels_and_extends():
177177
plt.colorbar()
178178

179179

180+
@image_comparison(baseline_images=['contour_vmax_over_colorbar_range'],
181+
extensions=['png'])
182+
def test_vmax_over_colorbar_range():
183+
xvec = np.linspace(0, 10)
184+
yvec = np.linspace(0, 20)
185+
X, Y = np.meshgrid(xvec, yvec)
186+
Z = X**2 + Y**2
187+
188+
plt.contourf(X, Y, Z, cmap='pink_r', vmax=700)
189+
plt.colorbar()
190+
191+
192+
@image_comparison(baseline_images=['contour_vmax_under_colorbar_range'],
193+
extensions=['png'])
194+
def test_vmax_under_colorbar_range():
195+
xvec = np.linspace(0, 10)
196+
yvec = np.linspace(0, 20)
197+
X, Y = np.meshgrid(xvec, yvec)
198+
Z = X**2 + Y**2
199+
200+
plt.contourf(X, Y, Z, cmap='pink_r', vmax=300)
201+
plt.colorbar()
202+
203+
180204
if __name__ == '__main__':
181205
import nose
182206
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)