赞
踩
ggplot2包由Hadley Wickham(2009a)编写,它提供了一种基于Wilkinson(2005)所描述的图形语法的图形系统,Wickham(2009b)还对该语法进行了扩展。ggplot2包的目标是提供一个全面的、基于语法的、连贯一致的图形生成系统,允许用户创建新颖的、有创新性的数据可视化图形。
ggplot2中,图通过+串联函数而创建,每个函数负责自己的部分。
ggplot(by_year_continent, aes(x = year, y = medianGdpPercap, color = continent, size = pop))+
geom_point()+ #点图
expand_limits(y = 0) + #y轴从0开始
scale_x_log10() + #x轴做log转换
labs(title = "plot1", x= "year", y = "median of GDP per cap")
函数 | 添加 | 选项 |
---|---|---|
geom_bar() | 条形图1 the height of the bar proportional to the number of cases in each group | color, fill, alpha |
geom_col() | 条形图2 the heights of the bars represents values in the data | color, fill, alpha |
geom_boxplot() | 箱线图 | color, fill, alpha, notch, width |
geom_density() | 密度图 | color, fill, alpha, linetype |
geom_histogram() | 直方图 | color, fill, alpha, linetype, binwidth |
geom_hline() | 水平线 | color, alpha, linetype, size |
geom_jitter() | 抖动点 | color, size, alpha, shape |
geom_line() | 线图 | color, alpha, linetype, size |
geom_point() | 散点图 | color, alpha, shape, size |
geom_rug() | 地毯图 | color, side |
geom_smooth() | 拟合曲线 | method, formula, color, fill, linetype, size |
geom_text() | 文字注解 | 很多,参见函数的“帮助” |
geom_violin() | 小提琴图 | color, fill, alpha, linetype |
geom_vline() | 垂线 | color, alpha, linetype, size |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。