我试图使用点图来表示样本数据和样本元数据。这两个数据都是连续的,数值数据,并分组为几个接受。不幸的是,我无法让连续的‘年龄’数据在geom_dotplot中工作,除非我使用factor()将其更改为分类数据,而且我也不知道为什么
samples.GN.df<- data.frame(
Protein1 = sample(1:30),
Accession = sample(c("yes", "no"), 30, replace = TRUE),
Age = sample(10:39)
)这不管用:
ggplot(samples.GN.df, aes(y=Protein1, x=Accession))+
geom_dotplot(binaxis = 'y', stackdir = 'center', mapping = aes(fill = Age))确实如此(虽然这些点不再整齐地堆叠起来,但接下来我可以解决这个问题):
ggplot(samples.GN.df, aes(y=Protein1, x=Accession))+
geom_dotplot(binaxis = 'y', stackdir = 'center', mapping = aes(fill = factor(Age)))我尝试过各种方法,让它作为连续的而不是离散的数据工作,但没有结果,它只是作为一个黑色的,甚至没有一个错误的信息指出我的正确方向。
在这方面的任何帮助都将受到感谢!
(编辑以添加示例数据)
发布于 2018-06-28 12:57:11
您只需将组添加到主映射中,并将连续填充映射添加到geom_dotplot中:
ggplot(samples.GN.df, aes(y=Protein1, x=Accession, group=factor(Age)) ) +
geom_dotplot(aes(fill=Age ), binaxis = 'y', stackdir = 'center')https://stackoverflow.com/questions/51068417
复制相似问题