MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / xkcd

Function xkcd

site-packages/matplotlib/pyplot.py:346–401  ·  view source on GitHub ↗

Turn on `xkcd `_ sketch-style drawing mode. This will only have effect on things drawn after this function is called. For best results, the "Humor Sans" font should be installed: it is not included with matplotlib. Parameters ---------- scale : f

(scale=1, length=100, randomness=2)

Source from the content-addressed store, hash-verified

344
345
346def xkcd(scale=1, length=100, randomness=2):
347 """
348 Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode.
349 This will only have effect on things drawn after this function is
350 called.
351
352 For best results, the "Humor Sans" font should be installed: it is
353 not included with matplotlib.
354
355 Parameters
356 ----------
357 scale : float, optional
358 The amplitude of the wiggle perpendicular to the source line.
359 length : float, optional
360 The length of the wiggle along the line.
361 randomness : float, optional
362 The scale factor by which the length is shrunken or expanded.
363
364 Notes
365 -----
366 This function works by a number of rcParams, so it will probably
367 override others you have set before.
368
369 If you want the effects of this function to be temporary, it can
370 be used as a context manager, for example::
371
372 with plt.xkcd():
373 # This figure will be in XKCD-style
374 fig1 = plt.figure()
375 # ...
376
377 # This figure will be in regular style
378 fig2 = plt.figure()
379 """
380 if rcParams['text.usetex']:
381 raise RuntimeError(
382 "xkcd mode is not compatible with text.usetex = True")
383
384 from matplotlib import patheffects
385 return rc_context({
386 'font.family': ['xkcd', 'Humor Sans', 'Comic Sans MS'],
387 'font.size': 14.0,
388 'path.sketch': (scale, length, randomness),
389 'path.effects': [patheffects.withStroke(linewidth=4, foreground="w")],
390 'axes.linewidth': 1.5,
391 'lines.linewidth': 2.0,
392 'figure.facecolor': 'white',
393 'grid.linewidth': 0.0,
394 'axes.grid': False,
395 'axes.unicode_minus': False,
396 'axes.edgecolor': 'black',
397 'xtick.major.size': 8,
398 'xtick.major.width': 3,
399 'ytick.major.size': 8,
400 'ytick.major.width': 3,
401 })
402
403

Callers

nothing calls this directly

Calls 1

rc_contextFunction · 0.90

Tested by

no test coverage detected