点的形状
R语言自带的点的形状

library(ggsci)
ggplot(data = small_diamonds, aes(x=carat, y=price)) +
geom_point(shape = 21, size = 5, color = "black", aes(fill = cut)) +
scale_fill_npg () +
theme_classic()

点的大小
ggplot(data = small_diamonds, aes(x=carat, y=price)) +
geom_point(shape = 21, color = "black", aes(fill = cut, size = price)) +
scale_fill_npg () +
scale_size(range = c(1,10)) +
theme_classic()

设置标题
ggplot(data = small_diamonds, aes(x=carat, y=price)) +
geom_point(shape = 21, size = 5, color = "black", aes(fill = cut)) +
scale_fill_npg () +
scale_y_continuous(breaks = c(5000, 10000, 15000),
labels = c('5K', '10K', '15K')) +
labs(title = 'point plot',
subtitle = 'my subtitle',
x = 'weight of the diamond',
y = 'price in US dollars',
fill = 'quality of the cut') +
theme_classic()

主题美化
ggplot(data = small_diamonds, aes(x=carat, y=price)) +
geom_point(shape = 21, size = 5, color = "black", aes(fill = cut)) +
scale_fill_npg () +
scale_y_continuous(breaks = c(5000, 10000, 15000),
labels = c('5K', '10K', '15K')) +
labs(title = 'point plot',
x = 'weight of the diamond',
y = 'price in US dollars',
fill = 'quality of the cut') +
theme_classic() +
theme(plot.title = element_text(hjust = 0.5,
size = 20),
axis.title = element_text(size = 15),
legend.position = c(0.15,0.85))

网友评论