Skip to content

Issue in course-content/projects/behavior /Loading_CalMS21_data.ipynb #1135

@verzep

Description

@verzep

Hi,

Presumably, due to an update in Matplotlib, the current version of this notebook throws an error when one tries to visualize the animal movements.

The error is in the previous cell and it can be fixed by substituting lines 86-90

    fig.canvas.draw()
    image_from_plot = np.frombuffer(fig.canvas.tostring_rgb(),
                                    dtype=np.uint8)
    image_from_plot = image_from_plot.reshape(
        fig.canvas.get_width_height()[::-1] + (3,))

with

    fig.canvas.draw()
    # Convert the figure to an RGB array using `fig.canvas.tostring_rgb()` before plotting.
    image_from_plot = np.frombuffer(fig.canvas.buffer_rgba(), dtype=np.uint8)
    # Reshape the RGB array to the correct dimensions.
    image_from_plot = image_from_plot.reshape(fig.canvas.get_width_height()[::-1] + (4,))  # RGBA
    image_from_plot = image_from_plot[:, :, :3]  # Convert RGBA to RGB by removing alpha channel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions