我的数据:
plot_df <-
structure(list(model = structure(c(1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Full",
"Point Differential"), class = "factor"), measure = structure(c(1L,
1L, 2L, 2L, 3L, 3L), .Label = c("AIC", "R^2", "Number of Predictors"
), class = "factor"), value = c(266.666394197942, 303.321585856894,
0.851698145309359, 0.713883491646847, 10, 1)), class = "data.frame", row.names = c(NA,
-6L))
我使用数据进行了以下绘制:
ggplot(plot_df, aes(y=value, x=model, fill=model)) +
geom_bar(position="dodge", stat="identity") +
facet_wrap(~measure, scales='free') +
labs(title='Model Comparison', x='', y='Value', fill='Model') +
geom_text(aes(label=round(value,2)),vjust=1.25) +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())
第二个facet_wrap()
窗格的标题为R^2
,但不是数学符号。我曾尝试使用labeller=label_parsed()
,但没有用。另外,我尝试使用latex2exp
包,但这也不起作用。有人知道如何解决这个问题吗?
答案 0 :(得分:3)