R语言柱状图和几何对象的绘制
library(tidyverse)
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, fill = cut))

library(tidyverse)
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut,fill = clarity))

library(tidyverse)
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = clarity,fill = clarity))

library(tidyverse)
ggplot(
data = diamonds,
mapping = aes(x = cut, fill = clarity)
) +
geom_bar(alpha = 1/5, position = "identity")
ggplot(
data = diamonds,
mapping = aes(x = cut, color = clarity)
) +
geom_bar(fill = clarity, position = "identity")

library(tidyverse)
ggplot(
data = diamonds,
mapping = aes(x = cut, fill = clarity)
) +
geom_bar(alpha = 2/5, position = "dodge")

library(tidyverse)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = class))

ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = factor(cyl)))

参考文献:R数据科学---[新西兰]哈德利 威克姆,[美]加勒特 格罗勒芒德---陈光欣[译] 北京:人民邮电出版社
开发环境:RStudio
- 点赞
- 收藏
- 关注作者
评论(0)