8000 Merge pull request #8776 from kbrose/updated-downsampling · matplotlib/matplotlib@170726d · GitHub
[go: up one dir, main page]

Skip to content

Commit 170726d

Browse files
authored
Merge pull request #8776 from kbrose/updated-downsampling
Updated downsampling
2 parents 0d0b1c1 + 66801d7 commit 170726d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2291
-1913
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Path simplification updates
2+
---------------------------
3+
4+
Line simplification controlled by the ``path.simplify`` and
5+
``path.simplify_threshold`` parameters has been improved. You should
6+
notice better rendering performance when plotting large amounts of
7+
data (as long as the above parameters are set accordingly). Only the
8+
line segment portion of paths will be simplified -- if you are also
9+
drawing markers and experiencing problems with rendering speed, you
10+
should consider using the ``markevery`` option to ``plot``.
11+
See the :ref:`performance` section in the usage tutorial for more
12+
information.
13+
14+
The simplification works by iteratively merging line segments
15+
into a single vector until the next line segment's perpendicular
16+
distance to the vector (measured in display-coordinate space)
17+
is greater than the ``path.simplify_threshold`` parameter. Thus, higher
18+
values of ``path.simplify_threshold`` result in quicker rendering times.
19+
If you are plotting just to explore data and not for publication quality,
20+
pixel perfect plots, then a value of ``1.0`` can be safely used. If you
21+
want to make sure your plot reflects your data *exactly*, then you should
22+
set ``path.simplify`` to false and/or ``path.simplify_threshold`` to ``0``.
23+
Matplotlib currently defaults to a conservative value of ``1/9``, smaller
24+
values are unlikely to cause any visible differences in your plots.

lib/matplotlib/path.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None):
206206
return pth
207207

208208
def _update_values(self):
209+
self._simplify_threshold = rcParams['path.simplify_threshold']
209210
self._should_simplify = (
211+
self._simplify_threshold > 0 and
210212
rcParams['path.simplify'] and
211-
(len(self._vertices) >= 128 and
212-
(self._codes is None or np.all(self._codes <= Path.LINETO)))
213+
len(self._vertices) >= 128 and
214+
(self._codes is None or np.all(self._codes <= Path.LINETO))
213215
)
214-
self._simplify_threshold = rcParams['path.simplify_threshold']
215216
self._has_nonfinite = not np.isfinite(self._vertices).all()
216217

217218
@property
Loading
Loading

0 commit comments

Comments
 (0)
0