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 edad75d

Browse filesBrowse files
committed
BUG: make clabel obey fontsize kwarg
1 parent 497ffa8 commit edad75d
Copy full SHA for edad75d

File tree

Expand file treeCollapse file tree

3 files changed

+16
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-13
lines changed

‎lib/matplotlib/contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/contour.py
+3-13Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,9 @@ def clabel(self, *args, **kwargs):
183183
self.labelIndiceList = indices
184184

185185
self.labelFontProps = font_manager.FontProperties()
186-
if fontsize is None:
187-
font_size = int(self.labelFontProps.get_size_in_points())
188-
else:
189-
if type(fontsize) not in [int, float, str]:
190-
raise TypeError("Font size must be an integer number.")
191-
# Can't it be floating point, as indicated in line above?
192-
else:
193-
if type(fontsize) == str:
194-
font_size = int(self.labelFontProps.get_size_in_points())
195-
else:
196-
self.labelFontProps.set_size(fontsize)
197-
font_size = fontsize
198-
self.labelFontSizeList = [font_size] * len(levels)
186+
self.labelFontProps.set_size(fontsize)
187+
font_size_pts = self.labelFontProps.get_size_in_points()
188+
self.labelFontSizeList = [font_size_pts] * len(levels)
199189

200190
if _colors is None:
201191
self.labelMappable = self
Loading

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ def test_contour_manual_labels():
166166
plt.clabel(cs, manual=pts)
167167

168168

169+
@image_comparison(baseline_images=['contour_labels_size_color'],
170+
extensions=['png'], remove_text=True)
171+
def test_contour_manual_labels():
172+
173+
x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
174+
z = np.max(np.dstack([abs(x), abs(y)]), 2)
175+
176+
plt.figure(figsize=(6, 2))
177+
cs = plt.contour(x, y, z)
178+
pts = np.array([(1.5, 3.0), (1.5, 4.4), (1.5, 6.0)])
179+
plt.clabel(cs, manual=pts, fontsize='small', colors=('r', 'g'))
180+
181+
169182
@image_comparison(baseline_images=['contour_manual_colors_and_levels'],
170183
extensions=['png'], remove_text=True)
171184
def test_given_colors_levels_and_extends():

0 commit comments

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