wilkelab / ggtext

Improved text rendering support for ggplot2
https://wilkelab.org/ggtext/
GNU General Public License v2.0
651 stars 37 forks source link

using switch in facet_grid breaks md output #61

Closed werkstattcodes closed 3 years ago

werkstattcodes commented 3 years ago

Many thanks for this wonderful package.

When switching the position of facets strips, the output is not as intended. Below a reprex.

library(ggtext)
library(tidyverse)

mtcars %>% 
  mutate(cyl=as.character(cyl)) %>% 
  mutate(cyl_rmd=case_when(cyl==4 ~ "<span style='color:red'>cyl</span>",
                           TRUE ~ cyl)) %>% 
  ggplot()+
  geom_point(aes(x=disp,
                 y=drat))+
  theme(
    strip.text.y=element_markdown()
  )+
  facet_grid(cyl_rmd~.)


mtcars %>% 
  mutate(cyl=as.character(cyl)) %>% 
  mutate(cyl_rmd=case_when(cyl==4 ~ "<span style='color:red'>cyl</span>",
                           TRUE ~ cyl)) %>% 
  ggplot()+
  geom_point(aes(x=disp,
                 y=drat))+
  theme(
    strip.text.y=element_markdown()
  )+
  facet_grid(cyl_rmd~.,
             switch = "y")

Created on 2021-03-12 by the reprex package (v1.0.0)

clauswilke commented 3 years ago

See #5.