I am relatively new to R. I am trying to plot a 3D scatterplot. I have 4 continuous variables, one of which defines the group. There are 6 groups.
I tried this code:
scatterplot3d(x,y,z,color=as.numeric(group),pch=20)
The colors are all too similar. How can I assign specific colors to the 6 groups?
Could you also tell me how to change the font to Calibri?
Thank you so much! :)
R, scatterplot3d: Assigning specific color to group and change font
1k views Asked by Sweezy At
1
For the font part, I'll refer you to this answer, which addresses it very well.
For the color part, you have to set up a color palette, and then use your numeric
group
variable to access the different colors in the palette.e.g
yields
You'll notice I didn't use scatterplot3d, because your question is actually unrelated to that function !
If you want pre-built color palettes, you can have a look at the
viridis
package or theRcolorBrewer
package.