I'm trying to use geom_bar for getting a bar plot
connected with lines.
How to draw connecting lines between samples?
ggplot()+
geom_bar(data = data_bar,
aes(x = Sample, y =Percentage, fill = Taxon),
colour = 'white', width =0.3, stat="identity")+
guides(fill= guide_legend(ncol = 1))
I tried it by using both geom_bar and geom_line, but it looks weird
.
It looks like connected line starts from the center of A sample to the center of B sample.
ggplot()+
geom_bar(data = data_bar,
aes(x = Sample, y =Percentage, fill = Taxon),
colour = 'white', width =0.3, stat="identity")+
geom_line(data = rev(data),
aes(x = Sample, y =Percentage, group = Taxon, color = Taxon),
size = 0.3, stat = 'identity')+
guides(fill= guide_legend(ncol = 1))
I want to get a better plot like connected line starts from the right edge on the bar of A sample to the left edge on the bar of B sample.
How can I make it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…