ggplot2作图4
程序员文章站
2022-07-14 21:04:07
...
??theme_bw()参数的使用
??theme_bw()
##用法,其他的几个内部参数相同
theme_grey(
base_size = 15,##整体布局字的缩放比例
base_family = "bold",##所有的字体
base_line_size = 1/10,##基本的线的粗细
base_rect_size = 1/2
)
mtcars2 <- within(mtcars, {
vs <- factor(vs, labels = c("V-shaped", "Straight"))
am <- factor(am, labels = c("Automatic", "Manual"))
cyl <- factor(cyl)
gear <- factor(gear)
})
p1 <- ggplot(mtcars2) +
geom_point(aes(x = wt, y = mpg, colour = gear)) +
labs(title = "Fuel economy declines as weight increases",
subtitle = "(1973-74)",
caption = "Data from the 1974 Motor Trend US magazine.",
tag = "Figure 1",
x = "Weight (1000 lbs)",
y = "Fuel economy (mpg)",
colour = "Gears")###关于标题和亚标题及图形字幕的说明
p1 + theme_gray() # the default 见图1
p1 + theme_bw()##背景灰色去掉了 见图2
p1 + theme_linedraw() 见图3
p1 + theme_light()##背景色在白色的基础上减轻 见图4
p1 + theme_dark()##深色背景 见图5
p1 + theme_minimal()##去除了四周的线 见图6
p1 + theme_classic()##去除除了x和y轴以外的线 见图7
p1 + theme_void()###完全去除背景,只剩下一张白纸画板 见图8
# Theme examples with panels
p2 <- p1 + facet_grid(vs ~ am)##分面设置,横坐标vs ,纵坐标am
p2 + theme_gray() # the default 见图9
p2 + theme_bw() ##图像界面的灰色被去掉 见图10
p2 + theme_linedraw() 见图11
p2 + theme_light() ##背景色在白色的基础上减轻 见图12
p2 + theme_dark()##图像界面的灰色被去掉 见图13
p2 + theme_minimal()##去掉外部线框 见图14
p2 + theme_classic() ##去掉内部的全部线条,只保留外围的线条 见图15
p2 + theme_void()##去掉所有的线条 见图16
p2+theme_grey(
base_size = 15,##整体布局字的缩放比例
base_family = "bold",##所有的字体
base_line_size = 1/10,##基本的线的粗细
base_rect_size = 1/2 ##正方形分面线的粗细
)
图1
图2
图3
图4
图5
图6
图7
图8
图9
图10
图11
图12
图13
图14
图15
图16
图19
下一篇: Lake Counting