Search code examples
rscatter-plotcran

Make grid lines bold that correspond to specific values in scatterplot3d


For the following 3d scatterplot,

require(scatterplot3d)
x <- c(1,4,3,6,2,5)
y <- c(2,2,4,3,5,9)
z <- c(1,3,5,9,2,2)
s <- scatterplot3d(x,y,z)

I want to emphasize (i.e. make bold) each grid line that corresponds to the value 4 on the x, y and z axes.

How might I go about doing so?

Thanks in advance!


Solution

  • Well, it doesn't look like there is a super straight forward way to do this in the scatter plot command itself, but you can find positions after you make the plot and draw on top.

    For example

    s <- scatterplot3d(x,y,z)
    with(s$xyz.convert(c(4,4),c(2,9),c(0,0)), lines(x, y, lwd=2))
    with(s$xyz.convert(c(1,6),c(4,4),c(0,0)), lines(x, y, lwd=2))
    

    Here we darken the gridlines on the bottom for x=4 and y=4. Not sure where you were picturing the line for z=4.

    3d scatter plot with highlighted grid marks