BUG: make clabel obey fontsize kwarg #5764

Merged
merged 1 commit into from Dec 31, 2015
View
@@ -183,19 +183,9 @@ def clabel(self, *args, **kwargs):
self.labelIndiceList = indices
self.labelFontProps = font_manager.FontProperties()
- if fontsize is None:
- font_size = int(self.labelFontProps.get_size_in_points())
- else:
- if type(fontsize) not in [int, float, str]:
- raise TypeError("Font size must be an integer number.")
- # Can't it be floating point, as indicated in line above?
- else:
- if type(fontsize) == str:
- font_size = int(self.labelFontProps.get_size_in_points())
- else:
- self.labelFontProps.set_size(fontsize)
- font_size = fontsize
- self.labelFontSizeList = [font_size] * len(levels)
+ self.labelFontProps.set_size(fontsize)
+ font_size_pts = self.labelFontProps.get_size_in_points()
+ self.labelFontSizeList = [font_size_pts] * len(levels)
if _colors is None:
self.labelMappable = self
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -166,6 +166,19 @@ def test_contour_manual_labels():
plt.clabel(cs, manual=pts)
+@image_comparison(baseline_images=['contour_labels_size_color'],
+ extensions=['png'], remove_text=True)
+def test_contour_manual_labels():
+
+ x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
+ z = np.max(np.dstack([abs(x), abs(y)]), 2)
+
+ plt.figure(figsize=(6, 2))
+ cs = plt.contour(x, y, z)
+ pts = np.array([(1.5, 3.0), (1.5, 4.4), (1.5, 6.0)])
+ plt.clabel(cs, manual=pts, fontsize='small', colors=('r', 'g'))
+
+
@image_comparison(baseline_images=['contour_manual_colors_and_levels'],
extensions=['png'], remove_text=True)
def test_given_colors_levels_and_extends():