在 R ggplot 中绘制计数直方图

CEP*_*HAS 4 r histogram ggplot2

我需要这方面的帮助。我在这里搜索过但没有得到正确的输出。

我正在尝试在 R 中绘制此图,因此我可以使用 GGplot 在单个图中并排绘制 3 个文件。我想要的输出(用excel绘制)是这样的

所需的直方图

我使用 GGplot 得到的是这个

ggplot 输出

我正在使用的R代码是这样的

A1 <- read.table("A1.txt", header = T, sep = "\t")
library(ggplot2)
ggplot(A1, aes(x = count)) + geom_bar()
Run Code Online (Sandbox Code Playgroud)

数据是一个制表符分隔的文件,如下所示

length  count
26  344776
27  289439
18  673395
28  338146
19  710702
20  928326
21  3491352
22  2724981
23  699007
24  726121
25  472509
Run Code Online (Sandbox Code Playgroud)

长度实际上只是 x 轴上绘制在 y 轴上的计数的标签。

ozg*_*ral 5

这是你想要的吗?

ggplot(A1, aes(x = as.character(length), y=count)) + geom_bar(stat="identity")