您可以在此页面中查看示例.
请注意,在theme_wsj
示例中,xlab
并ylab
没有出现.
这是一个包含标签的非ggthemes图:
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
xlab("Hello World: X axis") +
ylab("Hello World: Y axis")
Run Code Online (Sandbox Code Playgroud)
但是,当您添加theme_wsj
主题时,它们会消失:
ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
xlab("Hello World: X axis") +
ylab("Hello World: Y axis") +
theme_wsj()
Run Code Online (Sandbox Code Playgroud)
如果查看源代码,theme_wsj()
可以看到轴标题设置为空白
theme_wsj<-function(base_size=12, color="brown", base_family="sans", title_family="Courier") {
colorhex <- ggthemes_data$wsj$bg[color]
(theme_foundation()
+ theme(
.....
axis.title=element_blank()
....
Run Code Online (Sandbox Code Playgroud)
因此,获得xlab
和ylab
显示的一个解决方案是添加新的主题元素
+theme_wsj()+theme(axis.title=element_text(size=12))
Run Code Online (Sandbox Code Playgroud)