Reputation: 3590
Based on previous posts I worked out how to use expression()
to get a string within a string italicised while the rest of the string remains un-italicised. The problem is that element_text(face = "bold")
does not work on strings inside expression()
.
ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(bins = 10) +
ylab(expression(paste("% of group ", italic("n")))) +
xlab("Actual Treatment") +
theme(axis.title.x = element_text(face = "bold"),
axis.title.y = element_text(face = "bold"))
To get around this I wrapped the expression()
in bold()
like so
ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(bins = 10) +
ylab(expression(bold(paste("% of group ", italic("n"))))) +
xlab("Actual Treatment") +
theme(axis.title.x = element_text(face = "bold"))
But alas the italicised n remains unbolded. Any ideas?
Upvotes: 2
Views: 927
Reputation: 11
ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(bins = 10) +
labs(y=expression(bold(paste("% of group ", bolditalic("n"))),
x="Actual Treatment"))+
theme(axis.title.x = element_text(face = "bold"))
Upvotes: 0