Skip to content

Point size array in the Axes3D scatter() does not follow the same order as in the data points #18135

Closed
@chudur-budur

Description

@chudur-budur

Bug report

Bug summary
If I pass point sizes in an array through the s parameter in the scatter() function, the order of the values in s does not follow the same order as in the data points. I'm using scatter() function through Axes3D on jupyter notebook. The data to generate this issue can be found here.

Code for reproduction

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

P  = np.loadtxt("data.csv", delimiter=',')

S = np.array(np.ones(P.shape[0])) * 5.0 # set all data point sizes to 5.0
# The indices of the three extreme corners are 0, 43 and 989.
# Now set these three point sizes to 100
S[0] = 100
S[43] = 100
S[989] = 100

# Plot
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(P[:,0], P[:,1], P[:,2], s=S)
plt.show()

Actual outcome
I know the indices of the three extreme corners are 0, 43 and 989. Therefore, if I plot, those points should come up as the largest, but they don't.
fail-case

Now, if I do the same thing in a different way, it works. But it doesn't help since I need to pass the point sizes in an array, all at once.

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

P  = np.loadtxt("data.csv", delimiter=',')

# set these three point sizes to 100
I = np.array([0, 43, 989])

# Plot
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter(P[:,0], P[:,1], P[:,2], s=5)
ax.scatter(P[I,0], P[I,1], P[I,2], s=100)
plt.show()

Expected outcome (from the above code)

pass-case

Matplotlib version

  • Operating system: posix Darwin 19.6.0
  • Matplotlib version: 3.3.0
  • Matplotlib backend (print(matplotlib.get_backend())): nbAgg
  • Python version: 3.7.5
  • Jupyter version (if applicable):
    • jupyter core : 4.6.3
    • jupyter-notebook : 6.0.3
    • qtconsole : 4.7.5
    • ipython : 7.16.1
    • ipykernel : 5.3.4
    • jupyter client : 6.1.6
    • jupyter lab : not installed
    • nbconvert : 5.6.1
    • ipywidgets : 7.5.1
    • nbformat : 5.0.7
    • traitlets : 4.3.3
  • Other libraries: numpy 1.19.1, scipy 1.5.2
  • Browser: Firefox 78.0.2 (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions