Change colour of each marker depending on a 4th dimension

The easiest and most natural thing is to add jitter to your plot.

Data setup:

using Random


scatter3d(dat.x+rand(N)./10 .- 0.2, 
          dat.y+rand(N)./10 .- 0.2, 
          dat.z+rand(N)./10 .- 0.2)

enter image description here

However, if you want to use the colors this still can be done:


Having processed the data now let’s make a colormap (you might want to adjust it differently):

using Colors
cols = range(colorant"red", stop=colorant"green", length=maximum(dat2.nrow))

Time to plot:

scatter3d(dat2.x, dat2.y, dat2.z, color=cols[dat2.nrow])

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top