r - 使条形图中的条具有相同的高度

标签 r ggplot2

如何让条形图中的条具有相同的高度?

> head(data.m)
  Classes variable        value
1    rRNA  KO1.DOC 4.890821e+04
2    rRNA  KO1.DOC 3.068479e+03
3   Other  KO1.DOC 7.618553e+01
4   Other  KO1.DOC 4.043281e-01
5   Other  KO1.DOC 0.000000e+00
6   Other  KO1.DOC 0.000000e+00

ggplot(data.m, aes(variable, fill=Classes, order = -as.numeric(Classes))) +
  geom_bar(aes(y=value), position="stack", stat="identity") + 
  theme_bw(base_size=8)

enter image description here

最佳答案

答案是使用 position="fill" geom_bar :

# regular barplot
ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +
  geom_bar()
# "filled"
ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +
  geom_bar(position="fill")

关于r - 使条形图中的条具有相同的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31263535/

相关文章:

r - 高度按比例缩放的 ggridges

r - 如何在箱线图R中显示单独的误差线?

r - 带有自定义字体的ggplot在shinyapps.io上没有正确显示

R Shiny 使用 iframe 本地文件

c++ - rcpp 函数中的清理时间较长

r - 使用 summarize() 访问其他 group_by 组

r - 如何读取 ggraph 径向图中的文本标签

r - ggplot2:根据填充值为某些点设置alpha = 0

r - 子集有向图

r - 来自 read.csv 的数据摘要的水平 xtable