Skip to content

Commit 5c0812a

Browse files
committed
Changed Agg Fix
1 parent 5e1ae25 commit 5c0812a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/matplotlib/collections.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,11 @@ def draw(self, renderer):
388388
trans = self.get_transforms()
389389
facecolors = self.get_facecolor()
390390
edgecolors = self.get_edgecolor()
391+
linewidths = np.nan_to_num(self._linewidths, nan=0, posinf=0).clip(0)
391392
do_single_path_optimization = False
392393
if (len(paths) == 1 and len(trans) <= 1 and
393394
len(facecolors) == 1 and len(edgecolors) == 1 and
394-
len(self._linewidths) == 1 and
395+
len(linewidths) == 1 and
395396
all(ls[1] is None for ls in self._linestyles) and
396397
len(self._antialiaseds) == 1 and len(self._urls) == 1 and
397398
self.get_hatch() is None):
@@ -412,7 +413,7 @@ def draw(self, renderer):
412413

413414
if do_single_path_optimization:
414415
gc.set_foreground(tuple(edgecolors[0]))
415-
gc.set_linewidth(self._linewidths[0])
416+
gc.set_linewidth(linewidths[0])
416417
gc.set_dashes(*self._linestyles[0])
417418
gc.set_antialiased(self._antialiaseds[0])
418419
gc.set_url(self._urls[0])
@@ -433,7 +434,7 @@ def draw(self, renderer):
433434
gc, transform.frozen(), [],
434435
self.get_transforms(), offsets, offset_trf,
435436
self.get_facecolor(), self.get_edgecolor(),
436-
self._linewidths, self._linestyles,
437+
linewidths, self._linestyles,
437438
self._antialiaseds, self._urls,
438439
"screen", hatchcolors=self.get_hatchcolor()
439440
)
@@ -453,7 +454,7 @@ def draw(self, renderer):
453454
# First draw paths within the gaps.
454455
ipaths, ilinestyles = self._get_inverse_paths_linestyles()
455456
args = [offsets, offset_trf, [mcolors.to_rgba("none")], self._gapcolor,
456-
self._linewidths, ilinestyles, self._antialiaseds, self._urls,
457+
linewidths, ilinestyles, self._antialiaseds, self._urls,
457458
"screen"]
458459

459460
if hatchcolors_arg_supported:
@@ -478,7 +479,7 @@ def draw(self, renderer):
478479
renderer.draw_path(gc0, path, transform, rgbFace)
479480

480481
args = [offsets, offset_trf, self.get_facecolor(), self.get_edgecolor(),
481-
self._linewidths, self._linestyles, self._antialiaseds, self._urls,
482+
linewidths, self._linestyles, self._antialiaseds, self._urls,
482483
"screen"]
483484

484485
if hatchcolors_arg_supported:

src/_backend_agg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,7 @@ inline void RendererAgg::_draw_path_collection_generic(GCAgg &gc,
981981
gc.color = agg::rgba(edgecolors(ic, 0), edgecolors(ic, 1), edgecolors(ic, 2), edgecolors(ic, 3));
982982

983983
if (Nlinewidths) {
984-
double temp_lw = linewidths(i % Nlinewidths);
985-
gc.linewidth = (std::isfinite(temp_lw) && temp_lw > 0) ? temp_lw : 0.0;
984+
gc.linewidth = linewidths(i % Nlinewidths);
986985
} else {
987986
gc.linewidth = 1.0;
988987
}

0 commit comments

Comments
 (0)