ggplot2 logdensity内核估计

时间:2011-11-25 18:19:12

标签: r ggplot2 kernel-density

获得相同结果的最佳方法是: Kernel estimation of log-pdf

使用 ggplot2 而不是基本图形?我想用类似于stat_density的东西来做这件事,否则当与刻面等结合时,事情会变得很复杂。

2 个答案:

答案 0 :(得分:3)

library(ggplot2)

x = rnorm(100)

dev.new(width=4, height=4)
qplot(x, stat='density', geom='line') + scale_y_log10()

enter image description here

答案 1 :(得分:0)

难道你不能只指定dlog_y= log(density(x)$y)并将gglplot作为y变量调用吗?

x = rnorm(100); dlog_y= log()
dev.new(width=4, height=4)
qplot(x = density(x)$x, y=dlog_y)