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

[Doc]: documentation of how to properly rasterize output of contourf #27669

Closed
@tarrla

Description

@tarrla

Documentation Link

https://matplotlib.org/stable/gallery/images_contours_and_fields/contourf_demo.html

Problem

The contourf demo could use a clear example of how to properly rasterize the output. It may be useful to include this information directly in the contourf documentation.

Here's a minimal example that shows what used to work for me (based on the example in thecontourf demo and the top answer fromstackoverflow), but is now deprecated as of matplotlib 3.8:

import numpy as npimport matplotlib.pyplot as pltdelta = 0.025x = y = np.arange(-3.0, 3.01, delta)X, Y = np.meshgrid(x, y)Z1 = np.exp(-X**2 - Y**2)Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)Z = (Z1 - Z2) * 2fig, ax = plt.subplots()cont = ax.contourf(X,Y,Z, levels = 100)for c in cont.collections:    c.set_rasterized(True)

This now returns:

MatplotlibDeprecationWarning: The collections attribute was deprecated in Matplotlib 3.8 and will be removed two minor releases later.  for c in cont.collections:

It's not obvious to me how I should be rasterizing a contourf for matplotlib>=3.8 (regardless of whether the method I used above was sensical or not...at least it worked).

If I try to apply something similar to what is in the currentrasterization demo, (which I think resulted from#17708 ),

fig2, ax2 = plt.subplots()cont = ax2.contourf(X,Y,Z, levels = 100, rasterized=True)

then I get the following error:

UserWarning: The following kwargs were not used by contour: 'rasterized'  cont = ax2.contourf(X,Y,Z, levels = 100, rasterized=True)

Suggested improvement

  1. Include a paragraph and code snippet somewhere inhttps://matplotlib.org/stable/gallery/images_contours_and_fields/contourf_demo.html explaining how to rasterize contourf.

  2. maybe include a description of how to rasterize directly in the documentation of contourf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp