From a4b85b867af7ce5ae9170398fc80e6b0a7e60388 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 2 Nov 2018 10:24:51 +0100 Subject: [PATCH] Backport PR #12709: Correctly remove nans when drawing paths with pycairo. --- lib/matplotlib/backends/backend_cairo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_cairo.py b/lib/matplotlib/backends/backend_cairo.py index 80103fb50498..857e0622fd2d 100644 --- a/lib/matplotlib/backends/backend_cairo.py +++ b/lib/matplotlib/backends/backend_cairo.py @@ -90,7 +90,8 @@ def buffer_info(self): def _append_paths_slow(ctx, paths, transforms, clip=None): for path, transform in zip(paths, transforms): - for points, code in path.iter_segments(transform, clip=clip): + for points, code in path.iter_segments( + transform, remove_nans=True, clip=clip): if code == Path.MOVETO: ctx.move_to(*points) elif code == Path.CLOSEPOLY: @@ -118,7 +119,7 @@ def _append_paths_fast(ctx, paths, transforms, clip=None): # Convert curves to segment, so that 1. we don't have to handle # variable-sized CURVE-n codes, and 2. we don't have to implement degree # elevation for quadratic Beziers. - cleaneds = [path.cleaned(transform=transform, clip=clip, curves=False) + cleaneds = [path.cleaned(transform, remove_nans=True, clip=clip) for path, transform in zip(paths, transforms)] vertices = np.concatenate([cleaned.vertices for cleaned in cleaneds]) codes = np.concatenate([cleaned.codes for cleaned in cleaneds])