|
6 | 6 | import numpy as np |
7 | 7 | from numpy import ma |
8 | 8 | import matplotlib |
| 9 | +from matplotlib import rc_context |
9 | 10 | from matplotlib.testing.decorators import image_comparison, cleanup |
10 | 11 | import matplotlib.pyplot as plt |
11 | 12 | from matplotlib import rcParams |
@@ -258,27 +259,27 @@ def test_colorbarbase(): |
258 | 259 | baseline_images=['colorbar_closed_patch'], |
259 | 260 | remove_text=True) |
260 | 261 | def test_colorbar_closed_patch(): |
261 | | - fig = plt.figure(figsize=(8,6)) |
| 262 | + fig = plt.figure(figsize=(8, 6)) |
262 | 263 | ax1 = fig.add_axes([0.05, 0.85, 0.9, 0.1]) |
263 | 264 | ax2 = fig.add_axes([0.1, 0.65, 0.75, 0.1]) |
264 | 265 | ax3 = fig.add_axes([0.05, 0.45, 0.9, 0.1]) |
265 | 266 | ax4 = fig.add_axes([0.05, 0.25, 0.9, 0.1]) |
266 | 267 | ax5 = fig.add_axes([0.05, 0.05, 0.9, 0.1]) |
267 | 268 |
|
268 | | - cmap = cm.jet |
269 | | - cmap.set_under('w') |
270 | | - cmap.set_over('w') |
271 | | - |
272 | | - im = ax1.pcolormesh(np.linspace(0,10,16).reshape((4,4))) |
| 269 | + cmap = get_cmap("RdBu", lut=5) |
273 | 270 |
|
274 | | - plt.colorbar(im,cax=ax2,cmap=cmap,orientation='horizontal', |
275 | | - extend='both',extendfrac=0.5) |
276 | | - plt.colorbar(im,cax=ax3,cmap=cmap,orientation='horizontal', |
277 | | - extend='both',) |
278 | | - plt.colorbar(im,cax=ax4,cmap=cmap,orientation='horizontal', |
279 | | - extend='both',extendrect=True) |
280 | | - plt.colorbar(im,cax=ax5,cmap=cmap,orientation='horizontal', |
281 | | - extend='neither') |
| 271 | + im = ax1.pcolormesh(np.linspace(0, 10, 16).reshape((4, 4)), cmap=cmap) |
| 272 | + values = np.linspace(0, 10, 5) |
| 273 | + |
| 274 | + with rc_context({'axes.linewidth': 16}): |
| 275 | + plt.colorbar(im, cax=ax2, cmap=cmap, orientation='horizontal', |
| 276 | + extend='both', extendfrac=0.5, values=values) |
| 277 | + plt.colorbar(im, cax=ax3, cmap=cmap, orientation='horizontal', |
| 278 | + extend='both', values=values) |
| 279 | + plt.colorbar(im, cax=ax4, cmap=cmap, orientation='horizontal', |
| 280 | + extend='both', extendrect=True, values=values) |
| 281 | + plt.colorbar(im, cax=ax5, cmap=cmap, orientation='horizontal', |
| 282 | + extend='neither', values=values) |
282 | 283 |
|
283 | 284 |
|
284 | 285 | if __name__ == '__main__': |
|
0 commit comments