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

Skip to content

Added parameters to the xkcd function. Fixed deprecation warning on Path. #2038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ and Emf backends. See :ref:`changes_in_1_3` for a complete list.
To give your plots a sense of authority that they may be missing,
Michael Droettboom (inspired by the work of many others in
:ghpull:`1329`) has added an `xkcd-style <http://xkcd.com/>`_ sketch
plotting mode. To use it, simply call `pyplot.xkcd` before creating
your plot.
plotting mode. To use it, simply call :func:`matplotlib.pyplot.xkcd`
before creating your plot. For really fine control, it is also possible
to modify each artist's sketch parameters individually with
:meth:`matplotlib.artist.Artist.set_sketch_params`.

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

Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,10 @@ def cleaned(self, transform=None, remove_nans=False, clip=None,
Path instance with cleaned up vertices and codes.

"""
vertices, codes = cleanup_path(self, transform,
remove_nans, clip,
snap, stroke_width,
simplify, curves, sketch)
vertices, codes = _path.cleanup_path(self, transform,
remove_nans, clip,
snap, stroke_width,
simplify, curves, sketch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I think that was really just a merge oops more than anything else.

internals = {'should_simplify': self.should_simplify and not simplify,
'has_nonfinite': self.has_nonfinite and not remove_nans,
'simplify_threshold': self.simplify_threshold,
Expand Down
13 changes: 11 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def setp(*args, **kwargs):
return ret


def xkcd():
def xkcd(scale=1, length=100, randomness=2):
"""
Turns on `xkcd <http://xkcd.com/>`_ sketch-style drawing mode.
This will only have effect on things drawn after this function is
Expand All @@ -259,6 +259,15 @@ def xkcd():
For best results, the "Humor Sans" font should be installed: it is
not included with matplotlib.

Parameters
----------
scale: float, optional
The amplitude of the wiggle perpendicular to the source line.
length: float, optional
The length of the wiggle along the line.
randomness: float, optional
The scale factor by which the length is shrunken or expanded.

This function works by a number of rcParams, so it will probably
override others you have set before.

Expand All @@ -282,7 +291,7 @@ def xkcd():
try:
rcParams['font.family'] = ['Humor Sans', 'Comic Sans MS']
rcParams['font.size'] = 14.0
rcParams['path.sketch'] = (1, 100, 2)
rcParams['path.sketch'] = (scale, length, randomness)
rcParams['path.effects'] = [
patheffects.withStroke(linewidth=4, foreground="w")]
rcParams['axes.linewidth'] = 1.5
Expand Down