R 点绘图:如何根据数据中的值更改点绘图的点大小,并将所有x轴值转换为整数
我已经为我的数据绘制了一个点图,但需要帮助完成收尾工作。我在stackoverflow工作过一段时间,还没有看到任何直接回答我问题的帖子 我的点图代码为:R 点绘图:如何根据数据中的值更改点绘图的点大小,并将所有x轴值转换为整数,r,ggplot2,R,Ggplot2,我已经为我的数据绘制了一个点图,但需要帮助完成收尾工作。我在stackoverflow工作过一段时间,还没有看到任何直接回答我问题的帖子 我的点图代码为: ggplot()+ geom_dotplot(mapping = aes(x= reorder(Description, -p.adjust), y=Count, fill=-p.adjust), data = head(X[which(X$p.adjust < 0.05),], n = 15), binaxi
ggplot()+
geom_dotplot(mapping = aes(x= reorder(Description, -p.adjust), y=Count, fill=-p.adjust),
data = head(X[which(X$p.adjust < 0.05),], n = 15), binaxis = 'y', dotsize = 2,
method = 'dotdensity', binpositions = 'all', binwidth = NULL)+
scale_fill_continuous(low="black", high="light grey") +
labs(y = "Associated genes", x = "wikipathways", fill = "p.adjust") +
theme(axis.text=element_text(size=8)) +
ggtitle('') +
theme(plot.title = element_text(2, face = "bold", hjust = 1),
legend.key.size = unit(2, "line")) +
theme(panel.background = element_rect(fill = 'white', colour = 'black'))+
coord_fixed(ratio = 0.5)+
coord_flip()
要完成此绘图,我需要进行两次编辑
我想使用的基础上生成的点的大小,并在此大小的基础上制作一个辅助键。对于ggplot2和点图,这可能吗
接下来,我想将X轴值保持为整数。我希望避免使用scale_x_continuous(limits=c(2,10))之类的东西,因为此绘图代码是用于不同大小的多个数据集的函数的一部分。因此,包含限制/规模将不起作用
非常感谢您的帮助。如果您可以切换到geom_点图而不是geom_点图,则可以根据变量轻松调整点大小。它似乎还足够幸运地纠正了您的axis问题
ggplot(x)+
geom_point(mapping = aes(x= reorder(Description, -p.adjust), y=Count, fill=-p.adjust, size=GeneRatio),
data = head(x[which(x$p.adjust < 0.05),], n = 15), binaxis = 'y', #dotsize = 2,
method = 'dotdensity', binpositions = 'all', binwidth = NULL)+
scale_fill_continuous(low="black", high="light grey") +
labs(y = "Associated genes", x = "wikipathways", fill = "p.adjust") +
theme(axis.text=element_text(size=8)) +
ggtitle('') +
theme(plot.title = element_text(2, face = "bold", hjust = 1),
legend.key.size = unit(2, "line")) +
theme(panel.background = element_rect(fill = 'white', colour = 'black'))+
coord_fixed(ratio = 0.5)+
coord_flip()
ggplot(x)+
几何点(映射=aes(x=重新排序(描述,-p.adjust),y=计数,填充=-p.adjust,大小=生成),
数据=头部(x[x(x$p.adjust<0.05),],n=15),双轴='y',#dotsize=2,
方法='dotdensity',binpositions='all',binwidth=NULL)+
刻度填充连续(低=黑色,高=浅灰色)+
实验室(y=“相关基因”,x=“维基路径”,fill=“p.adjust”)+
主题(axis.text=element\u text(大小=8))+
标题(“”)+
主题(plot.title=element\u text(2,face=“bold”,hjust=1),
图例.key.size=单位(2,“线”))+
主题(panel.background=element_rect(填充为“白色”,颜色为“黑色”)+
固定坐标(比率=0.5)+
coord_flip()
ggplot(x)+
geom_point(mapping = aes(x= reorder(Description, -p.adjust), y=Count, fill=-p.adjust, size=GeneRatio),
data = head(x[which(x$p.adjust < 0.05),], n = 15), binaxis = 'y', #dotsize = 2,
method = 'dotdensity', binpositions = 'all', binwidth = NULL)+
scale_fill_continuous(low="black", high="light grey") +
labs(y = "Associated genes", x = "wikipathways", fill = "p.adjust") +
theme(axis.text=element_text(size=8)) +
ggtitle('') +
theme(plot.title = element_text(2, face = "bold", hjust = 1),
legend.key.size = unit(2, "line")) +
theme(panel.background = element_rect(fill = 'white', colour = 'black'))+
coord_fixed(ratio = 0.5)+
coord_flip()