Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axes3D scatter changes the color in version 1.2.1 during rotation #2564

Closed
alexgorb opened this issue Oct 31, 2013 · 6 comments
Closed

Axes3D scatter changes the color in version 1.2.1 during rotation #2564

alexgorb opened this issue Oct 31, 2013 · 6 comments

Comments

@alexgorb
Copy link

Scatter plot in Axes3D changes the color/alpha when rotating. Scatter became darker if closer to the viewer or lighter if far. I use matplotlib 1.2.1 following code:
import mpl_toolkits.mplot3d.axes3d as p3
fig = p.figure()

ax = p3.Axes3D(fig)

 ax=fig.add_subplot(111,projection='3d')
 ax.scatter(x[:,0],x[:,1],x[:,2],'o',c=cl,edgecolors=cl)

color table is custom array of tuples, one color tuple for each marker

@tacaswell
Copy link
Member

Related SO question:

http://stackoverflow.com/questions/8971309/matplotlib-3d-scatter-color-lost-after-redraw

     import mpl_toolkits.mplot3d.axes3d as p3
     fig = p.figure()
     #   ax = p3.Axes3D(fig)
     ax=fig.add_subplot(111,projection='3d')
     ax.scatter(x[:,0],x[:,1],x[:,2],'o',c=cl,edgecolors=cl)

(You use triple ` to offset code blocks of code)

@alexgorb
Copy link
Author

alexgorb commented Nov 1, 2013

Yes I know this post. I tried and it didnt work for me.

@alexgorb
Copy link
Author

alexgorb commented Nov 1, 2013

colours= [ ( 0.2600,0.6000,0.8200,1),
          ( 0.3000,0.6000,0.8200,1),
          ( 0.3400,0.6000,0.8000,1),
          ( 0.3800,0.6000,0.7800,1),
          ( 0.4200,0.6000,0.7600,1),
          ( 0.4600,0.6000,0.7400,1),
          ( 0.5000,0.6000,0.7200,1),
          ( 0.5400,0.6000,0.7000,1),
          ( 0.5600,0.6000,0.7000,1),
          ( 0.6000,0.6000,0.7000,1),
          ( 0.6400,0.6000,0.7000,1),
          ( 0.6800,0.6000,0.7000,1),
          ( 0.7200,0.6000,0.7000,1),
          ( 0.7600,0.6000,0.7000,1),
          ( 0.8000,0.6000,0.7000,1),
          ( 0.8400,0.6000,0.7000,1),
          ( 0.8800,0.6000,0.7200,1),
          ( 0.9200,0.6000,0.7400,1),
          ( 0.9600,0.6000,0.7600,1),
          ( 1.0000,0.6000,0.7800,1)]
     ax=fig.gca(projection='3d')
     ax.plot_wireframe(xgrid,ygrid,z_grid)
     cl=[]
     for i in xrange(len(x[:,0])):

          for j in xrange(len(colours)):
                     if (time[i]-time[0]) >= j*4. and (time[i]-time[0]) < (j+1)*4.:
                        ''' colours index should be j or -j-1 depending which order of palette you want to use '''
                        cl.append(colours[j])


     print cl
     global scatCollection
     scatCollection=ax.scatter(x[:,0],x[:,1],x[:,2],'o',c=cl,edgecolors=cl)
     def forceUpdate(event):
         global scatCollection
         scatCollection.changed()
         scatCollection.set_alpha(1.)

     fig.canvas.mpl_connect('draw_event',forceUpdate)

data are few samples taken within 0 to 70 seconds time. there are results during rotation:
image

image

@WeatherGod
Copy link
Member

This is a bug that was fixed a while ago. See
#1253

Please double-check your version by doing the following:

import matplotlib
print matplotlib.__version__

@alexgorb
Copy link
Author

alexgorb commented Nov 3, 2013

Python 2.7.2 (default, Apr 19 2013, 15:47:14)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib
matplotlib.version
'1.2.1'

@mdboom
Copy link
Member

mdboom commented Nov 4, 2013

Since we are no longer supporting 1.2.x, and this bug is fixed in 1.3.0, I'm going to close as fixed.

@mdboom mdboom closed this as completed Nov 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants