Closed AlexisZr closed 1 year ago
You're almost there, just apply cut()
to z
:
library(visreg)
fit <- lm(Ozone ~ Solar.R + Wind + Temp + I(Wind^2) + I(Temp^2) +
I(Wind*Temp)+I(Wind*Temp^2) + I(Temp*Wind^2) + I(Temp^2*Wind^2),
data=airquality)
v <- visreg2d(fit, x="Wind", y="Temp", plot=FALSE)
n_colors <- 99
color_palette <- colorRampPalette(c("blue","red"))(n_colors)
zcol <- cut(v$z, n_colors)
plot(v, plot.type="rgl", col=color_palette[zcol])
plot.Visreg2d
issueHey amazing work with
visreg
package!! I have a question regarding the color customization in the 3D plot. Is it possible to assign colors based on the values of the z-axis? In the provided image, the plot demonstrates a color gradient corresponding to the x-axis. However, I aim to achieve a similar gradient effect based on the z-axis values, where lower hazard ratios are represented by blue and higher hazard ratios by red. Could you kindly advise on how to accomplish this?"Steps to reproduce the issue