Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: using set_offsets on scatter object raises TypeError #21803

Closed
@gtimoshaz

Description

@gtimoshaz

Bug summary

plt.scatter can accept datetime as arguments, but set_offsets method of it's returns cannot.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10)
y = np.sin(x)
d = x * np.timedelta64(24, 'h') + np.datetime64('2021-11-29')

sc = plt.scatter(d, y) # shows a plot
sc.set_offsets(list(zip(d, y))) # clears the plot so it becomes just white square

Actual outcome

The scatters just disappear if you use other timedelta64 units than D, also if you use other date unit, than day.

Expected outcome

Excepted outcome is to update positions of scatters

Additional information

No response

Operating system

Arch

Matplotlib Version

3.5.0

Matplotlib Backend

Qt5Agg, 'module://ipympl.backend_nbagg'

Python version

Python 3.9.6

Jupyter version

3.1.7

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions