小编use*_*r03的帖子

在 ggplot2 中创建图例和添加图

我想使用ggplot2不同的颜色和图例在一个图中创建多个核密度图。我是通过以下方式完成的:

library(tidyverse)
set.seed(1234)
x <- rnorm(25)
x %>% tibble() %>% ggplot(aes(x = values)) +
  stat_density(aes(x, color = "0.1"), position = "identity", geom = "line", 
               kernel = "gaussian", bw = 0.1) +
  stat_density(aes(x, color = "0.2236"), position = "identity", geom = "line", 
               kernel = "gaussian", bw = 0.2236) +
  stat_density(aes(x, color = "0.334"), position = "identity", geom = "line", 
               kernel = "gaussian", bw = 0.334) +
  stat_density(aes(x, color = "0.578"), position = "identity", geom = "line", 
               kernel = "gaussian", …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

5
推荐指数
1
解决办法
77
查看次数

标签 统计

ggplot2 ×1

r ×1