Skip to content

Commit 527b7d9

Browse files
committed
Add a global rcParam 'path.snap' that, when False, turns off all pixel-snapping.
svn path=/trunk/matplotlib/; revision=8415
1 parent bd77bf2 commit 527b7d9

File tree

7 files changed

+34
-22
lines changed

7 files changed

+34
-22
lines changed

lib/matplotlib/artist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re, warnings
33
import matplotlib
44
import matplotlib.cbook as cbook
5-
from matplotlib import docstring
5+
from matplotlib import docstring, rcParams
66
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
77
from path import Path
88

@@ -414,7 +414,10 @@ def get_snap(self):
414414
415415
Only supported by the Agg and MacOSX backends.
416416
"""
417-
return self._snap
417+
if rcParams['path.snap']:
418+
return self._snap
419+
else:
420+
return False
418421

419422
def set_snap(self, snap):
420423
"""

lib/matplotlib/collections.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def draw(self, renderer):
211211

212212
gc = renderer.new_gc()
213213
self._set_gc_clip(gc)
214+
gc.set_snap(self.get_snap())
214215

215216
renderer.draw_path_collection(
216217
gc, transform.frozen(), paths, self.get_transforms(),

lib/matplotlib/config/mplconfig.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class lines(TConfig):
118118
class path(TConfig):
119119
simplify = T.false
120120
simplify_threshold = T.float(1.0 / 9.0)
121+
snap = T.true
121122

122123
class patch(TConfig):
123124
linewidth = T.Float(1.0)
@@ -444,7 +445,8 @@ def __init__(self, tconfig):
444445

445446
# Path properties
446447
'path.simplify' : (self.tconfig.path, 'simplify'),
447-
'path.simplify_threshold' : (self.tconfig.path, 'simplify_threshold')
448+
'path.simplify_threshold' : (self.tconfig.path, 'simplify_threshold'),
449+
'path.snap' : (self.tconfig.path, 'snap')
448450
}
449451

450452
def __setitem__(self, key, val):

lib/matplotlib/config/rcsetup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ def __call__(self, s):
476476
'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate
477477

478478
'path.simplify' : [True, validate_bool],
479-
'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)]
479+
'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)],
480+
'path.snap' : [True, validate_bool]
480481
}
481482

482483
if __name__ == '__main__':

lib/matplotlib/patches.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def draw(self, renderer):
356356
self._set_gc_clip(gc)
357357
gc.set_capstyle('projecting')
358358
gc.set_url(self._url)
359-
gc.set_snap(self._snap)
359+
gc.set_snap(self.get_snap())
360360

361361
if (not self.fill or self._facecolor is None or
362362
(cbook.is_string_like(self._facecolor) and self._facecolor.lower()=='none')):
@@ -3845,6 +3845,7 @@ def draw(self, renderer):
38453845
gc.set_antialiased(self._antialiased)
38463846
self._set_gc_clip(gc)
38473847
gc.set_capstyle('round')
3848+
gc.set_snap(self.get_snap())
38483849

38493850
if (not self.fill or self._facecolor is None or
38503851
(cbook.is_string_like(self._facecolor) and self._facecolor.lower()=='none')):

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,17 @@ def __call__(self, s):
546546

547547
'path.simplify' : [True, validate_bool],
548548
'path.simplify_threshold' : [1.0 / 9.0, ValidateInterval(0.0, 1.0)],
549+
'path.snap' : [True, validate_bool],
549550
'agg.path.chunksize' : [0, validate_int], # 0 to disable chunking;
550551
# recommend about 20000 to
551552
# enable. Experimental.
552553
# key-mappings
553-
'keymap.fullscreen' : ['f', validate_stringlist],
554+
'keymap.fullscreen' : ['f', validate_stringlist],
554555
'keymap.home' : [['h', 'r', 'home'], validate_stringlist],
555556
'keymap.back' : [['left', 'c', 'backspace'], validate_stringlist],
556557
'keymap.forward' : [['right', 'v'], validate_stringlist],
557558
'keymap.pan' : ['p', validate_stringlist],
558-
'keymap.zoom' : ['o', validate_stringlist],
559+
'keymap.zoom' : ['o', validate_stringlist],
559560
'keymap.save' : ['s', validate_stringlist],
560561
'keymap.grid' : ['g', validate_stringlist],
561562
'keymap.yscale' : ['l', validate_stringlist],

matplotlibrc.template

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ backend : %(backend)s
6363
# circles. See
6464
# http://matplotlib.sourceforge.net/api/artist_api.html#module-matplotlib.patches
6565
# information on patch properties
66-
#patch.linewidth : 1.0 # edge width in points
67-
#patch.facecolor : blue
68-
#patch.edgecolor : black
69-
#patch.antialiased : True # render patches in antialised (no jaggies)
66+
#patch.linewidth : 1.0 # edge width in points
67+
#patch.facecolor : blue
68+
#patch.edgecolor : black
69+
#patch.antialiased : True # render patches in antialised (no jaggies)
7070

7171
### FONT
7272
#
@@ -268,12 +268,12 @@ backend : %(backend)s
268268

269269
# The figure subplot parameters. All dimensions are fraction of the
270270
# figure width or height
271-
#figure.subplot.left : 0.125 # the left side of the subplots of the figure
272-
#figure.subplot.right : 0.9 # the right side of the subplots of the figure
273-
#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure
274-
#figure.subplot.top : 0.9 # the top of the subplots of the figure
275-
#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots
276-
#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots
271+
#figure.subplot.left : 0.125 # the left side of the subplots of the figure
272+
#figure.subplot.right : 0.9 # the right side of the subplots of the figure
273+
#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure
274+
#figure.subplot.top : 0.9 # the top of the subplots of the figure
275+
#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots
276+
#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots
277277

278278
### IMAGES
279279
#image.aspect : equal # equal | auto | a number
@@ -297,12 +297,15 @@ backend : %(backend)s
297297
# A value of 20000 is probably a good
298298
# starting point.
299299
### SAVING FIGURES
300-
#path.simplify : False # When True, simplify paths by removing "invisible"
300+
#path.simplify : True # When True, simplify paths by removing "invisible"
301301
# points to reduce file size and increase rendering
302302
# speed
303303
#path.simplify_threshold : 0.1 # The threshold of similarity below which
304304
# vertices will be removed in the simplification
305305
# process
306+
#path.snap : True # When True, rectilinear axis-aligned paths will be snapped to
307+
# the nearest pixel when certain criteria are met. When False,
308+
# paths will never be snapped.
306309

307310
# the default savefig params can be different from the display params
308311
# Eg, you may want a higher resolution, or to make the figure
@@ -362,12 +365,12 @@ backend : %(backend)s
362365
#verbose.fileo : sys.stdout # a log filename, sys.stdout or sys.stderr
363366

364367
# Event keys to interact with figures/plots via keyboard.
365-
# Customize these settings according to your needs.
366-
# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '')
368+
# Customize these settings according to your needs.
369+
# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '')
367370

368-
#keymap.fullscreen : f # toggling
371+
#keymap.fullscreen : f # toggling
369372
#keymap.home : h, r, home # home or reset mnemonic
370-
#keymap.back : left, c, backspace # forward / backward keys to enable
373+
#keymap.back : left, c, backspace # forward / backward keys to enable
371374
#keymap.forward : right, v # left handed quick navigation
372375
#keymap.pan : p # pan mnemonic
373376
#keymap.zoom : o # zoom mnemonic

0 commit comments

Comments
 (0)