R: stair ggplot

library(plotly)
library(ggplot2)

d=data.frame(x=c(1,2,4,5,7,8,9), y=c(1,2,3,5,6,7,9))

ggplot(data=d, mapping=aes(x=x, y=y)) +
geom_step(direction="h")+
geom_point(color="red") 


X轴必须是数值,因子报错
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?

ggplot(pan, aes(x=sort, y=samples_pan/1000000)) +
geom_step() +
geom_step(direction="h")+
geom_point(aes(color=Layer))+ 
labs(x="",y="Number of pan-genome (M)") +
theme_classic() +
theme(axis.text.x = element_text(angle=60,hjust=1,size=5))

参考
Stair Plots in ggplot2

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容