Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

element_markdown() not working with axis.title #59

Open
maia-sh opened this issue Feb 10, 2021 · 1 comment
Open

element_markdown() not working with axis.title #59

maia-sh opened this issue Feb 10, 2021 · 1 comment

Comments

@maia-sh
Copy link

maia-sh commented Feb 10, 2021

Thank you for this wonderful package! I am trying to add colors with html to title and axis labels. plot.title = element_markdown() works, however axis.title = element_markdown() does not. Based on the element_markdown() document I believe this should work for all text.


library(dplyr)
library(ggplot2)
library(ggtext)

mtcars %>% 
  ggplot(aes(x = mpg, y = cyl)) +
  geom_point() +
  labs(
    title = "I <span style='color:blue'>love</span> cars",
    x = "Look at this <span style='color:red'>mpg</span>!"
  ) +
  theme(
    plot.title = element_markdown(),
    axis.title = element_markdown()
  )

Created on 2021-02-10 by the reprex package (v0.3.0)

@delabj
Copy link

delabj commented Mar 31, 2021

It looks like you can solve this particular issue by specifying the axis you want to change like this.

library(dplyr)
library(ggplot2)
library(ggtext)

mtcars %>% 
  ggplot(aes(x = mpg, y = cyl)) +
  geom_point() +
  labs(
    title = "I <span style='color:blue'>love</span> cars",
    x = "Look at this <span style='color:red'>mpg</span>!"
  ) +
  theme(
    plot.title = element_markdown(),
    axis.title.x = element_markdown()
  )

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants