Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b02b701

Browse files
committed
Merge pull request #2038 from pelson/xkcd_args
Added parameters to the xkcd function. Fixed deprecation warning on Path.
2 parents 4d2699e + 053968e commit b02b701

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

doc/users/whats_new.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ and Emf backends. See :ref:`changes_in_1_3` for a complete list.
3636
To give your plots a sense of authority that they may be missing,
3737
Michael Droettboom (inspired by the work of many others in
3838
:ghpull:`1329`) has added an `xkcd-style <http://xkcd.com/>`_ sketch
39-
plotting mode. To use it, simply call `pyplot.xkcd` before creating
40-
your plot.
39+
plotting mode. To use it, simply call :func:`matplotlib.pyplot.xkcd`
40+
before creating your plot. For really fine control, it is also possible
41+
to modify each artist's sketch parameters individually with
42+
:meth:`matplotlib.artist.Artist.set_sketch_params`.
4143

4244
.. plot:: mpl_examples/showcase/xkcd.py
4345

lib/matplotlib/path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ def cleaned(self, transform=None, remove_nans=False, clip=None,
433433
Path instance with cleaned up vertices and codes.
434434
435435
"""
436-
vertices, codes = cleanup_path(self, transform,
437-
remove_nans, clip,
438-
snap, stroke_width,
439-
simplify, curves, sketch)
436+
vertices, codes = _path.cleanup_path(self, transform,
437+
remove_nans, clip,
438+
snap, stroke_width,
439+
simplify, curves, sketch)
440440
internals = {'should_simplify': self.should_simplify and not simplify,
441441
'has_nonfinite': self.has_nonfinite and not remove_nans,
442442
'simplify_threshold': self.simplify_threshold,

lib/matplotlib/pyplot.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def setp(*args, **kwargs):
250250
return ret
251251

252252

253-
def xkcd():
253+
def xkcd(scale=1, length=100, randomness=2):
254254
"""
255255
Turns on `xkcd <http://xkcd.com/>`_ sketch-style drawing mode.
256256
This will only have effect on things drawn after this function is
@@ -259,6 +259,15 @@ def xkcd():
259259
For best results, the "Humor Sans" font should be installed: it is
260260
not included with matplotlib.
261261
262+
Parameters
263+
----------
264+
scale: float, optional
265+
The amplitude of the wiggle perpendicular to the source line.
266+
length: float, optional
267+
The length of the wiggle along the line.
268+
randomness: float, optional
269+
The scale factor by which the length is shrunken or expanded.
270+
262271
This function works by a number of rcParams, so it will probably
263272
override others you have set before.
264273
@@ -282,7 +291,7 @@ def xkcd():
282291
try:
283292
rcParams['font.family'] = ['Humor Sans', 'Comic Sans MS']
284293
rcParams['font.size'] = 14.0
285-
rcParams['path.sketch'] = (1, 100, 2)
294+
rcParams['path.sketch'] = (scale, length, randomness)
286295
rcParams['path.effects'] = [
287296
patheffects.withStroke(linewidth=4, foreground="w")]
288297
rcParams['axes.linewidth'] = 1.5

0 commit comments

Comments
 (0)