版权声明:本套课程材料开源,使用和分享必须遵守「创作共用许可协议 CC BY-NC-SA」(来源引用-非商业用途使用-以相同方式共享)。
主要认识两套经典调色板:Brewer和Viridis。
## ggplot基础图形对象设定(赋值给p,避免重复写代码)
p = ggplot(
data = na.omit(airquality),
mapping = aes(x=Solar.R, y=Ozone, color=(Temp-32)/1.8)
)
p = p +
geom_point() +
labs(x="Solar Radiation",
y="Ozone Pollution",
color="Temp.")
p # 默认配色p + scale_color_fermenter(palette = "RdYlBu",
direction = -1,
limits = c(10, 40),
breaks = seq(10, 40, 3))"magma" (or "A")"inferno" (or "B")"plasma" (or "C")"viridis" (or "D")"cividis" (or "E")"rocket" (or "F")"mako" (or "G")"turbo" (or "H")(1)theme()主题元素设置函数(自学theme()函数帮助文档)
theme()函数共144个参数!(以下列出了常用参数)
plot.*)
plot.backgroundplot.title,
plot.title.positionplot.subtitleplot.caption,
plot.caption.positionplot.tag, plot.tag.positionplot.marginpanel.*)
panel.backgroundpanel.gridpanel.grid.majorpanel.grid.minoraxis.*)
axis.lineaxis.titleaxis.textaxis.tickslegend.*)
legend.backgroundlegend.position,
legend.position.insidelegend.directionlegend.titlelegend.textlegend.ticksstrip.*)
strip.backgroundstrip.text(2)element_*()元素属性设置函数(自学element_*()系列函数帮助文档)
element_blank():设置为空(移除该元素)element_rect():设置矩形元素(边框与底色)element_line():设置线条元素element_text():设置文本元素作业要求:
平台提交:
学号-姓名-R期末作业.Rmd学号-姓名-R期末作业.html