Kom*_*thi 7 r bar-chart ggplot2
我有一个数据帧:
>picard
count reads
1 20681318
2 3206677
3 674351
4 319173
5 139411
6 117706
Run Code Online (Sandbox Code Playgroud)
如何在ggplot(barplot)上绘制log10(计数)与log10(读数)?
我试过了:
ggplot(picard) + geom_bar(aes(x=log10(count),y=log10(reads)))
Run Code Online (Sandbox Code Playgroud)
但它不接受y = log10(读取).如何绘制y值?
jub*_*uba 10
你可以做这样的事情,但是用log10刻度绘制不连续的x轴对我来说没有意义:
ggplot(picard) +
geom_bar(aes(x=count,y=reads),stat="identity") +
scale_y_log10() +
scale_x_log10()
Run Code Online (Sandbox Code Playgroud)

如果您只想要一个带有log10比例的y轴,只需执行以下操作:
ggplot(picard) +
geom_bar(aes(x=count,y=reads),stat="identity") +
scale_y_log10()
Run Code Online (Sandbox Code Playgroud)

使用stat="identity":
ggplot(picard) + geom_bar(aes(x=log10(count),y=log10(reads)), stat="identity")
Run Code Online (Sandbox Code Playgroud)
实际上,您的方法会收到警告:
将变量映射到 y 并使用 stat="bin"。使用 stat="bin",它将尝试将 y 值设置为每组中的案例数。这可能会导致意外行为,并且在 ggplot2 的未来版本中将不允许。如果您希望 y 代表个案计数,请使用 stat="bin" 并且不要将变量映射到 y。如果您希望 y 代表数据中的值,请使用 stat="identity"。有关示例,请参阅 ?geom_bar。(已弃用;最后使用于版本 0.9.2)