..level.. in ggplot2 contour plot

前端 未结 1 577
小鲜肉
小鲜肉 2021-02-20 09:35

I find this variable a little confusing, for example, from the docs:

require(ggplot2)
require(reshape2)
volcano3d <- melt(volcano) 
names(volcano3d) <- c(\         


        
相关标签:
1条回答
  • 2021-02-20 09:56

    From Hadley Wickham's A Layered Grammar of Graphics, page 21, the .. .. is used because the aesthetic (in this case, the levels of the contours) is not present in the original dataset, but instead is calculated by the contour statistic.

    The two dots are a visual indicator highlighting that variable is not present in the original data, but has been computed by the statistic.

    You can't use colour=as.factor(z) or size=as.factor(z) because the graphic doesn't use z, but instead uses a statistical transformation of it - namely, ..level..

    0 讨论(0)
提交回复
热议问题