Adding a 3rd Variable to a stat_density_2d Plot
问题 Below is code and a dataset of a stat_density_2d plot I created in R. library(ggplot2) topKzone <- 3.5 botKzone <- 1.6 inKzone <- -0.95 outKzone <- 0.95 kZone <- data.frame( x=c(inKzone, inKzone, outKzone, outKzone, inKzone), y=c(botKzone, topKzone, topKzone, botKzone, botKzone) ) df$h <- round(df$platelocheight) df$s <- round(df$platelocside) df$es<- round(df$exitspeed) ggplot(kZone, aes(x,y)) + stat_density_2d(data=df, aes(x=s, y=h),geom="polygon") + scale_fill_distiller(palette = "Spectral