Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R编程-(ggpubr)如何添加图例来注释中心趋势?_R_Ggpubr - Fatal编程技术网

R编程-(ggpubr)如何添加图例来注释中心趋势?

R编程-(ggpubr)如何添加图例来注释中心趋势?,r,ggpubr,R,Ggpubr,我目前正在进行编码,我想创建一个直方图,显示数据集的平均值和中值。然而,我无法向观众传达这些线条中的哪一条代表平均值和中间值 如何添加图例和编辑标题,以便能够将这些内容传达给观众 虚拟代码: library(correlation) library(ggpubr) data("iris") PL <- gghistogram(iris, x = "Petal.Length", bins = 8, color

我目前正在进行编码,我想创建一个直方图,显示数据集的平均值和中值。然而,我无法向观众传达这些线条中的哪一条代表平均值和中间值

如何添加图例和编辑标题,以便能够将这些内容传达给观众

虚拟代码:

library(correlation)
library(ggpubr)


data("iris")

PL <- gghistogram(iris, x = "Petal.Length", bins = 8,
                  color = "black", fill = "#c68ed1",
                  title = "The Length of the Petals",
                  xlab = "Length of the Petal (cms)",
                  ylab = "Amount of Petals")

PL +
  font("title", size = 14, face = "italic") +
  font("xlab", size = 12, face = "bold") +
  font("ylab", size = 12, face = "bold") +
  geom_vline(aes(xintercept = mean(iris$Petal.Length)), col = "#f50018", size = 1) +
  geom_vline(aes(xintercept = median(iris$Petal.Length)), col = "#2128ab", size = 1)
库(相关性)
图书馆(ggpubr)
数据(“iris”)
PL