matplotlib/matplotlib — pull request #2176 by kthyng (2013-06-29 15:14:34+00:00)
Title: Adjustments to contour.py so that levels are set accordingly to input vmin and vmax, if provided, so color bar works correctly.

Previously, if a user wanted to include a vmin/vmax value to a call to contour or contourf, the plot itself would reflect the desired color range, but if a color bar was added to the plot, it would not nicely reflect the desired data range. This change fixes that problem by adding in a check for vmin and vmax in _contour_args() as input arguments and uses the values to set the levels in the data according to the desired data range. This works for whether the desired data range (from vmin/vmax) are within or without the actual data range, or whatever combination of the two. With this change, a plot made with pcolor and a color bar and a plot made with contourf and a color bar will behave similarly. The actual max and min boundary limits for the contour colorbars will not necessarily be equal to the input vmin and vmax because contour will still choose nice nearby contour values, but now those nice nearby values will be near the desired vmin and vmax. This work was done during the SciPy 2013 matplotlib sprint.