向散点图添加标签
Adding labels to a scatterplot
我有一个名为 PSCfull1 的数据框,其中包含 3 列:Gene、OrganoidCM、ControlCM。 "Gene"是一个基因列表,另外2列有数值。我制作了一个散点图:
ggplot(PSCfull1, aes(x=OrganoidCM, y=ControlCM))+geom_point(size=2, shape=16)+geom_text(label=rownames(PSCfull1))
它看起来不错,但标签是数字而不是第 1 列中基因的名称。如何让标签成为名称而不是行号?谢谢!
您应该告诉 ggplot 标签保存在您的基因列中:
ggplot(PSCfull1, aes(x = OrganoidCM, y = ControlCM, label = Gene)) +
geom_point(size=2, shape=16) +
geom_text()
我有一个名为 PSCfull1 的数据框,其中包含 3 列:Gene、OrganoidCM、ControlCM。 "Gene"是一个基因列表,另外2列有数值。我制作了一个散点图:
ggplot(PSCfull1, aes(x=OrganoidCM, y=ControlCM))+geom_point(size=2, shape=16)+geom_text(label=rownames(PSCfull1))
它看起来不错,但标签是数字而不是第 1 列中基因的名称。如何让标签成为名称而不是行号?谢谢!
您应该告诉 ggplot 标签保存在您的基因列中:
ggplot(PSCfull1, aes(x = OrganoidCM, y = ControlCM, label = Gene)) +
geom_point(size=2, shape=16) +
geom_text()