ggplot堆积条形图订购

时间:2019-10-09 14:14:48

标签: r ggplot2

我有一个数据框:

   income               race count   percent     pos label
1    >50K Amer-Indian-Eskimo    36 11.575563    18.0  <NA>
2   <=50K Amer-Indian-Eskimo   275 88.424437   173.5  <NA>
3    >50K Asian-Pac-Islander   276 26.564004   138.0   27%
4   <=50K Asian-Pac-Islander   763 73.435996   657.5   73%
5    >50K              Black   387 12.387964   193.5   12%
6   <=50K              Black  2737 87.612036  1755.5   88%
7    >50K              Other    25  9.225092    12.5  <NA>
8   <=50K              Other   246 90.774908   148.0  <NA>
9    >50K              White  7117 25.585994  3558.5   26%
10  <=50K              White 20699 74.414006 17466.5   74%

我想制作一个堆叠的条形图,其中最大值位于条形图的底部,但我对此无所适从。 ggplot的代码如下:

ggplot(df4,aes(x=race, y = count, fill = income)) + geom_bar(stat = "identity")

当前图输出:

enter image description here

0 个答案:

没有答案