Skip to content

3D scatterplots do not generate legend correctly #18096

@OGordon100

Description

@OGordon100

Bug report

Bug summary

Creating a 3d scatterplot with ax.scatter() and the "c" argument for colour only produces 1 legend entry

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = np.random.rand(20)
y = np.random.rand(20)
z = np.random.rand(20)
c = np.random.randint(low=0, high=4, size=20)
ax.scatter(x,y,z,c=c)
leg = [1,2,3, 4]
ax.legend(leg)

Actual outcome

Output Image

Expected outcome

The legend should have separate entries for "1", "2", "3", "4"

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.3.0 (also exists at least as far back as 3.2.2)
  • Matplotlib backend (TkAgg):
  • Python version: 3.6.3
  • Jupyter version (if applicable): N/A
  • Other libraries: Numpy
pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions