[Bug]: Surface draws incorrectly after set_verts on Poly3DCollection · Issue #21163 · matplotlib/matplotlib · GitHub
Skip to content

[Bug]: Surface draws incorrectly after set_verts on Poly3DCollection  #21163

Description

@ccaprani

Bug summary

Surface is not rendered properly after changing the data using set_verts: the simple MWE below shows the effect.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

x = np.array([10, -10])
y = np.array([25, -25])
z = 5

X, Y = np.meshgrid(x, y)
Z = z * np.ones_like(X)

fig = plt.figure(figsize=(8, 4.5))
ax = fig.add_subplot(projection="3d")

ax.axes.set_xlim3d(left=-15, right=15)
ax.axes.set_ylim3d(bottom=-30, top=30)
ax.axes.set_zlim3d(bottom=0, top=10)

surf = ax.plot_surface(X, Y, Z, color="r", alpha=0.3)
plt.pause(1.0)

time = np.linspace(0, 5, 101)
for t in time:
    zt = z + 2 * np.sin(2 * np.pi * t)
    Z = zt * np.ones_like(X)
    verts = np.array([X, Y, Z]).T.reshape(4, 3)
    surf.set_verts(verts)
    plt.pause(0.1)

Actual outcome

image

Expected outcome

The full surface, as is shown prior to updating using set_verts should be shown:

image

Operating system

Ubuntu 21.04

Matplotlib Version

3.4.2

Matplotlib Backend

Qt5Agg

Python version

3.8.11

Jupyter version

No response

Other libraries

No response

Installation

conda

Conda channel

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: mplot3d

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions