Skip to content
  • Sponsor matplotlib/matplotlib

  • Notifications You must be signed in to change notification settings
  • Fork 7.9k

scatter - set_facecolors is not working on Axes3D #9725

Closed
@orena1

Description

@orena1

Bug report

Bug summary

Trying to replicate this code: https://matplotlib.org/examples/animation/rain.html , but in Axes3D does not work, it seems that it is not possible to change the facecolors of the scatter while axes is 3D (it does work in 2d)

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import matplotlib.cm as cmx
from mpl_toolkits.mplot3d import Axes3D
plt.figure()
jet = cm = plt.get_cmap('jet')
cNorm  = matplotlib.colors.Normalize(vmin=1, vmax=10)
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)

cells = 10
ax = plt.subplot(1,1,1, projection='3d')
pos = np.random.uniform(0, 1, (10, 3))

scat = ax.scatter(pos[:,0],pos[:,1],pos[:,2],
                edgecolors=None,
                  facecolors= [scalarMap.to_rgba(1) for cond in range(10)])

scat.set_facecolors([scalarMap.to_rgba(10) for cond in range(10)])
plt.show()
##the dots should be red, but they are blue

Matplotlib version

  • Operating system: MacOs
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 2.7.14
  • Jupyter version (if applicable):
  • Other libraries:

Activity

changed the title [-]scatter, set_facecolors is not working on Axes3D[/-] [+]scatter - set_facecolors is not working on Axes3D[/+] on Nov 9, 2017
afvincent

afvincent commented on Nov 9, 2017

@afvincent
Contributor

@orena1 Thank you for the report :).

I can confirm that the dots were already blue since at least Matplotlib 1.5.3. (they probably never turned red...)

Here is a smaller MWE, with a possible workaround for the moment (though I am not 100% sure why it works):

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

plt.figure()
ax = plt.subplot(1, 1, 1, projection='3d')

pos = np.random.uniform(0, 1, (10, 3))

scat = ax.scatter(pos[:, 0], pos[:, 1], pos[:, 2],
                  edgecolors="none",
                  facecolors="blue")

scat.set_facecolors("red")

# Possible workaround that seems to trigger
# the update of the facecolor values
scat.set_3d_properties(pos[:, 2], "y")

plt.show()

Attn @WeatherGod

modified the milestones: v2.2, v2.1.1 on Nov 9, 2017
modified the milestones: v2.1.1, v2.2 on Nov 13, 2017
tacaswell

tacaswell commented on Nov 13, 2017

@tacaswell
Member

Moved to 2.2 as this is not a regression.

modified the milestone: needs sorting on Mar 5, 2018

17 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      scatter - set_facecolors is not working on Axes3D · Issue #9725 · matplotlib/matplotlib