Multiple colors in axis title

Hello,

I am trying to change the color of just one word from the y axis text title, but I created the title like an object inside expression function and I can't find a code that works for change the color in this funciton.

Here is the graph code:

x5 <- expression(IMA~(m^3~ha^-1)~e~ICA~(m^3~ha^-1~ano^-1)) # Y axis title

graf <- ggplot(out_i, aes(x=age)) +
geom_line(aes(y=volume_mai), size= 0.5, color = "red") +
geom_line(aes(y=ica), size= 0.5, color = "black") +
scale_x_continuous(breaks = seq(0,20,1), name = "Idade (Anos)") +
scale_y_continuous(limits=c(0,100,5), name = x5) +
theme_light() +
theme(axis.title = element_text(size = 7),
axis.text = element_text(size = 7),
axis.text.x = element_text(color = "black")) +
ggtitle(paste(d_site$pesquisa[i]))

I'm trying to change the word "IMA" to red.

Can someone help?

Have a look at ggtext

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.