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

Skip to content

Commit cdbbd94

Browse files
committed
Fix path simplification by a) making it more conservative about when it will simplify based on segment length, and b) honoring path.simplify rcParam in Agg backend.
svn path=/trunk/matplotlib/; revision=6712
1 parent 784dd69 commit cdbbd94

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/matplotlib/config/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def __call__(self, s):
479479
'svg.embed_char_paths' : [True, validate_bool], # True to save all characters as paths in the SVG
480480
'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate
481481

482-
'path.simplify' : [False, validate_bool]
482+
'path.simplify' : [True, validate_bool]
483483
}
484484

485485
if __name__ == '__main__':

lib/matplotlib/path.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ def __init__(self, vertices, codes=None):
109109
assert vertices.ndim == 2
110110
assert vertices.shape[1] == 2
111111

112-
self.should_simplify = (len(vertices) >= 128 and
113-
(codes is None or np.all(codes <= Path.LINETO)))
112+
self.should_simplify = (rcParam['path.simplify'] and
113+
(len(vertices) >= 128 and
114+
(codes is None or np.all(codes <= Path.LINETO))))
114115
self.has_nonfinite = not np.isfinite(vertices).all()
115116
self.codes = codes
116117
self.vertices = vertices

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def __call__(self, s):
518518
'docstring.hardcopy' : [False, validate_bool], # set this when you want to generate hardcopy docstring
519519
'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate
520520

521-
'path.simplify' : [False, validate_bool],
521+
'path.simplify' : [True, validate_bool],
522522
'agg.path.chunksize' : [0, validate_int] # 0 to disable chunking;
523523
# recommend about 20000 to
524524
# enable. Experimental.

src/agg_py_path_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class SimplifyPath
353353

354354
//if the perp vector is less than some number of (squared)
355355
//pixels in size, then merge the current vector
356-
if (perpdNorm2 < 0.25)
356+
if (perpdNorm2 < (1.0 / 9.0))
357357
{
358358
//check if the current vector is parallel or
359359
//anti-parallel to the orig vector. If it is parallel, test

0 commit comments

Comments
 (0)