MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_labels

Function test_labels

lib/matplotlib/tests/test_contour.py:262–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260 tol=1 if parse_version(np.version.version).major < 2 else
261 0 if platform.machine() == 'x86_64' else 0.005)
262def test_labels():
263 # Adapted from pylab_examples example code: contour_demo.py
264 # see issues #2475, #2843, and #2818 for explanation
265 delta = 0.025
266 x = np.arange(-3.0, 3.0, delta)
267 y = np.arange(-2.0, 2.0, delta)
268 X, Y = np.meshgrid(x, y)
269 Z1 = np.exp(-(X**2 + Y**2) / 2) / (2 * np.pi)
270 Z2 = (np.exp(-(((X - 1) / 1.5)**2 + ((Y - 1) / 0.5)**2) / 2) /
271 (2 * np.pi * 0.5 * 1.5))
272
273 # difference of Gaussians
274 Z = 10.0 * (Z2 - Z1)
275
276 fig, ax = plt.subplots(1, 1)
277 CS = ax.contour(X, Y, Z)
278 disp_units = [(216, 177), (359, 290), (521, 406)]
279 data_units = [(-2, .5), (0, -1.5), (2.8, 1)]
280
281 CS.clabel()
282
283 for x, y in data_units:
284 CS.add_label_near(x, y, inline=True, transform=None)
285
286 for x, y in disp_units:
287 CS.add_label_near(x, y, inline=True, transform=False)
288
289
290def test_label_contour_start():

Callers

nothing calls this directly

Calls 4

add_label_nearMethod · 0.80
subplotsMethod · 0.45
contourMethod · 0.45
clabelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…