标签:ggplot2 R语言
在R上运行如下代码,结果如下:
Market_Size
# A tibble: 7 x 3
year size speed
<dbl> <dbl> <dbl>
1 2009 44.4 NA
2 2010 58.9 32.8
3 2011 89.4 51.6
4 2012 117. 31.1
5 2013 163. 39.3
6 2014 199. 21.8
7 2015 236. 18.8
ggplot() + geom_bar(data = Market_Size, aes(x = year, y = size), colour="gray", size=1)
Error: stat_count() must not be used with a y aesthetic.
于是我查找了一下函数的默认值:
?geom_bar
geom_bar(mapping = NULL, data = NULL, stat = "count",
position = "stack", ..., width = NULL, binwidth = NULL,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
发现stat
的默认值是“count”
,于是我修改了默认值,再次作图:
ggplot() + geom_bar(data = Market_Size, aes(x = year, y = size), stat="identity", colour="gray", size=1)
大功告成!
geom_bar.jpeg
网友评论