R语言 (3) ggplot2

2017-07-31  本文已影响0人  无事扯淡

1.图像语法

Paste_Image.png ggplot2分层概念

2.基础

> library(ggplot2)
> help(mtcars)

字段描述
A data frame with 32 observations on 11 variables.

[, 1] mpg Miles/(US) gallon
[, 2] cyl Number of cylinders
[, 3] disp Displacement (cu.in.)
[, 4] hp Gross horsepower
[, 5] drat Rear axle ratio
[, 6] wt Weight (1000 lbs)
[, 7] qsec 1/4 mile time
[, 8] vs V/S
[, 9] am Transmission (0 = automatic, 1 = manual)
[,10] gear Number of forward gears
[,11] carb Number of carburetors

3.简单示例

> ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
重量wt与单位里程mpg关系
> ggplot(mtcars, aes(x = wt, y = mpg, color = disp)) +
  geom_point()
重量wt与单位里程mpg关系
ggplot(mtcars, aes(x = wt, y = mpg, size = disp)) +
  geom_point()
重量wt与单位里程mpg关系 Paste_Image.png

3.各类图像

上一篇 下一篇

猜你喜欢

热点阅读