Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addrasterized option tocontourf#29582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rcomer merged 8 commits intomatplotlib:mainfromAdamOrmondroyd:rasterizecontourf
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletionslib/matplotlib/contour.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
import matplotlib.cbook as cbook
import matplotlib.patches as mpatches
import matplotlib.transforms as mtransforms
from . import artist


def _contour_labeler_event_handler(cs, inline, inline_spacing, event):
Expand DownExpand Up@@ -767,6 +768,7 @@ def __init__(self, ax, *args,
edgecolor="none",
# Default zorder taken from Collection
zorder=kwargs.pop("zorder", 1),
rasterized=kwargs.pop("rasterized", False),
)

else:
Expand DownExpand Up@@ -1254,6 +1256,7 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):

return (i_level, segment, index, xmin, ymin, d2)

@artist.allow_rasterization
def draw(self, renderer):
paths = self._paths
n_paths = len(paths)
Expand DownExpand Up@@ -1681,6 +1684,13 @@ def _initialize_x_y(self, z):
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER

rasterized : bool, optional
*Only applies to* `.contourf`.
Rasterize the contour plot when drawing vector graphics. This can
speed up rendering and produce smaller files for large data sets.
See also :doc:`/gallery/misc/rasterization_demo`.


Notes
-----
1. `.contourf` differs from the MATLAB version in that it does not draw
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletionslib/matplotlib/tests/test_contour.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -837,3 +837,13 @@ def test_allsegs_allkinds():
assert len(result) == 2
assert len(result[0]) == 5
assert len(result[1]) == 4


@image_comparison(baseline_images=['contour_rasterization'],
extensions=['pdf'], style='mpl20', savefig_kwarg={'dpi': 25})
def test_contourf_rasterize():
fig, ax = plt.subplots()
data = [[0, 1], [1, 0]]
circle = mpatches.Circle([0.5, 0.5], 0.5, transform=ax.transAxes)
cs = ax.contourf(data, clip_path=circle, rasterized=True)
assert cs._rasterized
Loading

[8]ページ先頭

©2009-2025 Movatter.jp