在R中如何使用ggplot绘制正态分布的尾部区域?

问题描述 投票:2回答:1

[我找到了一种通过组合两个geom_area图以创建具有尾部区域的正态分布的方法来“破解” ggplot的方法:

library(ggplot2)
mean <-  0
standard_deviation <- 1
Zscore <- -1.35

observation = (Zscore*standard_deviation) + mean
(tail_area <- round(pnorm(observation),2))

ggplot(NULL, aes(c(-5,5))) +
    geom_area(stat = "function", fun = dnorm, fill="sky blue", xlim = c(-5, -1.35)) +
    geom_area(stat = "function", fun = dnorm,  xlim = c(-1.35, 5))

enter image description here

是否有使用ggplot创建正态分布并突出显示上述尾部区域的方法?

[我找到了一种通过组合两个geom_area图以创建具有尾部区域的正态分布来“破解” ggplot的方法:library(ggplot2)mean

r ggplot2 data-science normal-distribution
1个回答
5
投票

首先,我喜欢您的方法;不知道这是否少一些“ hackey”,但这是另一个使用gghighlight

© www.soinside.com 2019 - 2024. All rights reserved.