8000 Miscellaneous fixes mentioned in the PR · matplotlib/matplotlib@9652004 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9652004

Browse files
committed
Miscellaneous fixes mentioned in the PR
1 parent cc61700 commit 9652004

File tree

8 files changed

+68
-46
lines changed

8 files changed

+68
-46
lines changed

doc/users/whats_new.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ new in matplotlib-1.3
2424
`xkcd`-style sketch plotting
2525
----------------------------
2626

27-
To gives your plots a sense of authority that they may be missing,
28-
Michael Droettboom (inspired by the work of many others in `issue
29-
#1329 <https://github.com/matplotlib/matplotlib/pull/1329>`_) has
30-
added an `xkcd-style <xkcd.com>`_ sketch plotting mode. To use it,
31-
simply call `pyplot.xkcd` before creating your plot.
27+
To give your plots a sense of authority that they may be missing,
28+
Michael Droettboom (inspired by the work of many others in
29+
:ghpull:`1329`) has added an `xkcd-style <http://xkcd.com/>`_ sketch
30+
plotting mode. To use it, simply call `pyplot.xkcd` before creating
31+
your plot.
3232

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

35+
Path effects on lines
36+
---------------------
37+
Thanks to Jae-Joon Lee, path effects now also work on plot lines.
38+
39+
.. plot:: mpl_examples/pylab_examples/patheffect_demo.py
3540

3641
Changes to font rcParams
3742
------------------------

examples/pylab_examples/patheffect_demo.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
txt.set_path_effects([PathEffects.withStroke(linewidth=3,
1515
foreground="w")])
16-
txt.arrow_patch.set_path_effects([PathEffects.Stroke(linewidth=5,
17-
foreground="w"),
18-
PathEffects.Normal()])
16+
txt.arrow_patch.set_path_effects([
17+
PathEffects.Stroke(linewidth=5, foreground="w"),
18+
PathEffects.Normal()])
1919

2020
ax1.grid(True, linestyle="-")
2121

@@ -29,16 +29,12 @@
2929
ax2.imshow(arr)
3030
cntr = ax2.contour(arr, colors="k")
3131

32-
plt.setp(cntr.collections,
33-
path_effects=[PathEffects.withStroke(linewidth=3,
34-
foreground="w")])
35-
32+
plt.setp(cntr.collections, path_effects=[
33+
PathEffects.withStroke(linewidth=3, foreground="w")])
3634

3735
clbls = ax2.clabel(cntr, fmt="%2.0f", use_clabeltext=True)
38-
plt.setp(clbls,
39-
path_effects=[PathEffects.withStroke(linewidth=3,
40-
foreground="w")])
41-
36+
plt.setp(clbls, path_effects=[
37+
PathEffects.withStroke(linewidth=3, foreground="w")])
4238

4339
# shadow as a path effect
4440
ax3 = plt.subplot(133)
@@ -47,4 +43,3 @@
4743
leg.legendPatch.set_path_effects([PathEffects.withSimplePatchShadow()])
4844

4945
plt.show()
50-

examples/pylab_examples/to_numeric.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@
3030
X.shape = h, w, 3
3131

3232
im = Image.fromstring( "RGB", (w,h), s)
33+
34+
# Uncomment this line to display the image using ImageMagick's
35+
# `display` tool.
3336
# im.show()

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ def tk_window_focus():
11881188
'matplotlib.tests.test_mathtext',
11891189
'matplotlib.tests.test_mlab',
11901190
'matplotlib.tests.test_patches',
1191+
'matplotlib.tests.test_patheffects',
11911192
'matplotlib.tests.test_pickle',
11921193
'matplotlib.tests.test_rcparams',
11931194
'matplotlib.tests.test_scale',

lib/matplotlib/artist.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,20 @@ def set_snap(self, snap):
460460

461461
def get_sketch_params(self):
462462
"""
463-
Returns the sketch parameters, which is a tuple with three elements:
463+
Returns the sketch parameters for the artist.
464464
465-
* *scale*: The amplitude of the wiggle perpendicular to the
465+
Returns
466+
-------
467+
sketch_params : tuple or `None`
468+
469+
A 3-tuple with the following elements:
470+
471+
* `scale`: The amplitude of the wiggle perpendicular to the
466472
source line.
467473
468-
* *length*: The length of the wiggle along the line.
474+
* `length`: The length of the wiggle along the line.
469475
470-
* *randomness*: The scale factor by which the length is
476+
* `randomness`: The scale factor by which the length is
471477
shrunken or expanded.
472478
473479
May return `None` if no sketch parameters were set.
@@ -476,18 +482,23 @@ def get_sketch_params(self):
476482

477483
def set_sketch_params(self, scale=None, length=None, randomness=None):
478484
"""
479-
Sets the the sketch parameters:
485+
Sets the the sketch parameters.
480486
481-
* *scale*: The amplitude of the wiggle perpendicular to the
482-
source line, in pixels.
487+
Parameters
488+
----------
483489
484-
* *length*: The length of the wiggle along the line, in
485-
pixels (default 128.0)
490+
scale : float, optional
491+
The amplitude of the wiggle perpendicular to the source
492+
line, in pixels. If scale is `None`, or not provided, no
493+
sketch filter will be provided.
486494
487-
* *randomness*: The scale factor by which the length is
488-
shrunken or expanded (default 16.0)
495+
length : float, optional
496+
The length of the wiggle along the line, in pixels
497+
(default 128.0)
489498
490-
If *scale* is None, no wiggling will be set.
499+
randomness : float, optional
500+
The scale factor by which the length is shrunken or
501+
expanded (default 16.0)
491502
"""
492503
if scale is None:
493504
self._sketch = None

lib/matplotlib/backend_bases.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,14 +1007,20 @@ def get_hatch_path(self, density=6.0):
10071007

10081008
def get_sketch_params(self):
10091009
"""
1010-
Returns the sketch parameters, which is a tuple with three elements:
1010+
Returns the sketch parameters for the artist.
10111011
1012-
* *scale*: The amplitude of the wiggle perpendicular to the
1012+
Returns
1013+
-------
1014+
sketch_params : tuple or `None`
1015+
1016+
A 3-tuple with the following elements:
1017+
1018+
* `scale`: The amplitude of the wiggle perpendicular to the
10131019
source line.
10141020
1015-
* *length*: The length of the wiggle along the line.
1021+
* `length`: The length of the wiggle along the line.
10161022
1017-
* *randomness*: The scale factor by which the length is
1023+
* `randomness`: The scale factor by which the length is
10181024
shrunken or expanded.
10191025
10201026
May return `None` if no sketch parameters were set.
@@ -1023,18 +1029,23 @@ def get_sketch_params(self):
10231029

10241030
def set_sketch_params(self, scale=None, length=None, randomness=None):
10251031
"""
1026-
Sets the the sketch parameters:
1032+
Sets the the sketch parameters.
10271033
1028-
* *scale*: The amplitude of the wiggle perpendicular to the
1029-
source line.
1034+
Parameters
1035+
----------
10301036
1031-
* *length*: The length of the wiggle along the line, in
1032-
pixels.
1037+
scale : float, optional
1038+
The amplitude of the wiggle perpendicular to the source
1039+
line, in pixels. If scale is `None`, or not provided, no
1040+
sketch filter will be provided.
10331041
1034-
* *randomness*: The scale factor by which the length is
1035-
shrunken or expanded, in pixels.
1042+
length : float, optional
1043+
The length of the wiggle along the line, in pixels
1044+
(default 128.0)
10361045
1037-
If *scale* is None, no wiggling will be set.
1046+
randomness : float, optional
1047+
The scale factor by which the length is shrunken or
1048+
expanded (default 16.0)
10381049
"""
10391050
if scale is None:
10401051
self._sketch = None

lib/matplotlib/collections.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,13 @@ def draw(self, renderer):
264264
gc.set_sketch_params(*self.get_sketch_params())
265265

266266
if self.get_path_effects():
267-
#from patheffects import PathEffectsRenderer
268267
for pe in self.get_path_effects():
269268
pe.draw_path_collection(renderer,
270269
gc, transform.frozen(), paths, self.get_transforms(),
271270
offsets, transOffset, self.get_facecolor(), self.get_edgecolor(),
272271
self._linewidths, self._linestyles, self._antialiaseds, self._urls,
273272
self._offset_position)
274273
else:
275-
276274
renderer.draw_path_collection(
277275
gc, transform.frozen(), paths, self.get_transforms(),
278276
offsets, transOffset, self.get_facecolor(), self.get_edgecolor(),

lib/matplotlib/patheffects.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def __init__(self):
2222
super(_Base, self).__init__()
2323

2424
def get_proxy_renderer(self, renderer):
25-
pe_renderer = ProxyRenderer(self, renderer)
26-
return pe_renderer
25+
return ProxyRenderer(self, renderer)
2726

2827
def _update_gc(self, gc, new_gc_dict):
2928
new_gc_dict = new_gc_dict.copy()
@@ -96,7 +95,6 @@ def draw_path_collection(self, renderer,
9695
transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo)
9796
self.draw_path(renderer, gc0, path, transform, rgbFace)
9897

99-
10098
def draw_tex(self, renderer, gc, x, y, s, pro 4323 p, angle, ismath='TeX!'):
10199
self._draw_text_as_path(renderer, gc, x, y, s, prop, angle, ismath="TeX")
102100

0 commit comments

Comments
 (0)
0