Skip to content

Commit 3ef8b23

Browse files
committed
implement hybrid approach
1 parent 1c3e605 commit 3ef8b23

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/matplotlib/backends/backend_pdf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,19 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
21352135
facecolors, edgecolors, linewidths, linestyles,
21362136
antialiaseds, urls, offset_position, hatchcolors=hatchcolors):
21372137

2138+
# Optimization: Fast path for markers with centers inside canvas.
2139+
# This avoids the dictionary lookup for the common case where
2140+
# markers are visible, improving performance for large scatter plots.
2141+
if 0 <= xo <= canvas_width and 0 <= yo <= canvas_height:
2142+
# Marker center is inside canvas - definitely render it
2143+
self.check_gc(gc0, rgbFace)
2144+
dx, dy = xo - lastx, yo - lasty
2145+
output(1, 0, 0, 1, dx, dy, Op.concat_matrix, path_id,
2146+
Op.use_xobject)
2147+
lastx, lasty = xo, yo
2148+
continue
2149+
2150+
# Marker center is outside canvas - check if partially visible.
21382151
# Skip markers completely outside visible canvas bounds to reduce
21392152
# PDF file size. Use per-marker extents to handle large markers
21402153
# correctly: only skip if the marker's bounding box doesn't

0 commit comments

Comments
 (0)