这是我的初始条形码代码:
Full %>% ggplot(aes(x = reorder(POS, -Iconicity), y = Iconicity, fill = Group)) +
geom_bar(stat = "summary", position=position_dodge(width = 0.9)) +
scale_fill_viridis_d() + # color-blind compatible colors
theme_minimal() + xlab("POS")
哪个创建了这个可爱的图表:
所以我想把它变成一个棒棒糖图,使它看起来更整洁,更现代,这是我使用的代码:
Full %>% ggplot(aes(x = reorder(POS, -Iconicity), y = Iconicity, color = Group)) +
geom_point(size=3, stat = "summary", position=position_dodge(width = 0.9)) +
geom_segment(aes(x=POS,
xend=POS,
y=0,
yend=Iconicity)) +
scale_fill_viridis_d() + # color-blind compatible colors
theme_minimal() + xlab("POS")
但是,这当然不能在正确的位置添加足够多的段,而且我似乎无法弄清楚如何更改代码。我剩下的是这个:
我显然仍然是R的新手,请原谅我
我认为问题是由于您总结了geom_point
而不是geom_segment
,而您正在使用position_dodge
中的geom_point
。
没有什么是Full
的可复制示例,很难确定,但也许您可以尝试:
Full %>%
group_by(Group) %>%
summarise(Iconicity = mean(Iconicity, na.rm = TRUE)) %>%
ggplot(aes(x = reorder(POS, -Iconicity), y = Iconicity, color = Group)) +
geom_point(size=3,position=position_dodge(width = 0.9)) +
geom_segment(aes(x=POS,
xend=POS,
y=0,
yend=Iconicity), position = position_dodge(0.9) ) +
scale_fill_viridis_d() + # color-blind compatible colors
theme_minimal() + xlab("POS")
它回答了您的问题吗?
如果没有,请提供您的Full
数据集的可复制示例(请参见此链接:How to make a great R reproducible example)