gpt4 book ai didi

r - ggplot2:如何更改条形/列几何形状中颜色美感的宽度?

转载 作者:行者123 更新时间:2023-12-02 20:15:01 24 4
gpt4 key购买 nike

我正在制作一个柱形图/条形图,其中我使用一个变量更改fill美学(条形图的内部颜色),以及颜色美学(条形图周围的颜色) )与另一个变量。条形周围的颜色不容易看到,所以我想增加该条形的宽度。我怎样才能做到这一点?我在 scale_color_manual 中没有看到任何 width 参数?

library(ggplot2)

dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5),
r = factor(1:5))
data <- data_frame(x = rep("a", 4),
y = c(1,2,4,3),
categ = c("1", "2", "3", "4"),
group = rep(c("a", "b"), each=2))

ggplot(data, aes(x, y, fill= categ, colour=group)) +
geom_col() +
scale_color_manual(values = c("red", "blue"))

谢谢!

enter image description here

最佳答案

您可以使用size参数

ggplot(data, aes(x, y, fill= categ, colour=group)) + 
geom_col(size=3) + ### change
scale_color_manual(values = c("red", "blue"))

产生这个:

enter image description here

关于r - ggplot2:如何更改条形/列几何形状中颜色美感的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52598679/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com