美文网首页
R: 分组散点图

R: 分组散点图

作者: 胡童远 | 来源:发表于2021-11-25 11:28 被阅读0次

输入数据

数据预处理

排序,设因子,melt

library(ggplot2)
library(reshape2)

df3 = df3[order(df3$Richness, decreasing=F),]
df3$Sample = factor(df3$Sample, levels = df3$Sample)

input = melt(df3, id='Sample')

ggplot画图

p=
ggplot(input, aes(x=Sample, y=value, color=variable)) +
  geom_point() +
  geom_line(aes(group=variable)) +
  labs(y="Number", color="") +
  theme_classic() +
    theme(axis.title = element_text(size = 15),
        axis.text = element_text(size = 13),
        axis.text.x = element_text(angle = 60, hjust = 1),
        axis.line = element_line(size = 1),
        axis.ticks = element_line(size = 1),
        title = element_text(size = 12))

ggsave(p, file="tmp.png")

相关文章

网友评论

      本文标题:R: 分组散点图

      本文链接:https://www.haomeiwen.com/subject/mepatrtx.html