小编mnm*_*mnm的帖子

ggplot中轴的默认文本颜色

如果满足条件,我想更改 ggplot 中 x 轴文本的颜色。没问题,但为此,我必须知道theme_minimal(). 我查看了源代码,theme_bw()这让我theme_grey()找到了你可以在这里找到的源代码:https : //github.com/tidyverse/ggplot2/blob/master/R/theme-defaults.r 我看到许多声明颜色但不是其中之一x-axis?

r ggplot2

4
推荐指数
1
解决办法
1060
查看次数

ggplot抛出错误“找不到标签”,而“标签”显然在那里

我可以画出下面的标签df使用geom_text:

df <- data.frame(
  x = c(610, 426, 569, 253), 
  y = c(-226, -276, -364, -185), 
  label = c("accomplishments per week", "hours worked per week", "perceived adequacy of accomplishments", "energy level"),
  stringsAsFactors = FALSE
)

ggplot(df, aes(x, y)) + geom_text(aes(label = label))
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

但是,当尝试对真实数据使用相同的绘图机制时,出现错误:

Error in FUN(X[[i]], ...) : object 'label' not found

为什么会这样,我该如何解决?


这是我的真实数据df1:

df1 <- structure(list(type = c("var", "var", "var", "var"),
                  id = c(1,2, 4, 7), 
                  x = c(610, 426, …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

4
推荐指数
1
解决办法
100
查看次数

如何在 R 中找到箱线图的上限和下限?

在此输入图像描述我已经在 R 中使用某些参数构建了一个箱线图,但我不知道 xc2xb4t 代码来帮助我了解箱体的上限和下限。如果有人可以帮助我,我将不胜感激。我知道数量只是不知道上限和下限。

\n

r boxplot

3
推荐指数
1
解决办法
3868
查看次数

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

我找到了一种通过组合两个 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))
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

是否有使用 ggplot 创建正态分布并像上面一样突出显示尾部区域的“不那么hackey”的方法?

r normal-distribution ggplot2 data-science

3
推荐指数
1
解决办法
477
查看次数

标签 统计

r ×4

ggplot2 ×3

boxplot ×1

data-science ×1

normal-distribution ×1