【发布时间】:2019-07-28 17:50:52
【问题描述】:
我有以下情节,但 x 轴标签太小而无法阅读。如果我增加它们的大小,它们就会重叠且难以辨认
I have tried the code form the following link
但我得到一个错误''by'argument in'wrong sign'
我也尝试了以下链接 How to show every second R ggplot2 x-axis label value?
但作为初学者,我不能完全按照代码进行操作,也不确定标签是日期是否会增加复杂性。
我有 170 个样本的 100 个基因的 df + 一个“基因”列。然后我使用以下代码使数据变长:
mat_dataNew<-mat_data %>% gather(sample, expression, -Genes)
#log10-transform Counts data
mat_dataNew <- mutate(mat_dataNew, log10_NormCounts = log10(expression))
然后我绘制:
ggplot(mat_dataNew, aes(x=reorder(Genes, -log10_NormCounts), y=log10_NormCounts, colour=Group)) +
geom_point(size=.5) +
theme(axis.text.x=element_text(angle=90, size=4)) +
labs(x = "100 most abundant Genes", y = "Gene Expression (Log10 Normalised Counts)")
我尝试阅读有关 scale_x_continuous 但似乎找不到答案。您能否帮忙推荐一些代码,以便 x 轴标签清晰可见?我想也许最简单的选择是显示所有其他标签???
【问题讨论】:
-
使用 coor_flip() 将文本放在 y 轴上并使其更具可读性如何? ggplot2.tidyverse.org/reference/coord_flip.html
-
你真的需要展示100个基因吗?从你展示的情节来看,看起来很多都非常相似
-
你想要
scale_x_discrete而不是scale_x_continuous -
仅供参考,您可以使用
fct_lump()将相似的基因集中到一个新的“其他”级别r4ds.had.co.nz/factors.html#modifying-factor-levels