wilkelab / ggtext

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

letters are overlapping when using ggtext & ggiraph on mobile device #62

Open werkstattcodes opened 3 years ago

werkstattcodes commented 3 years ago

I am trying to produce a plot using ggplot, ggtext, and ggiraph. The plot title should contain some words in color. The code below works fine as long as I look at the produced graph on a larger screen (laptop is ok). When I look at it on a mobile device, the letters are overlapping.

I tried to isolate the problem and put it online here:

I had also put on a related SO question, but to no avail. Many thanks.

library(ggtext)
library(ggiraph)
library(tidyverse)

my_plot <- mtcars %>% 
  ggplot()+
  labs(title=glue::glue("this is a very long title, with many lines and a line <br>break etc etc etc, this <br>word is in <span style='color:red;'>red</span> or something else etc etc"))+
  geom_point_interactive(aes(x=wt,
                             y=qsec,
                             tooltip=paste(wt, qsec)))+
   theme(plot.title=element_markdown())

girafe(ggobj = my_plot,
       fonts=list(sans="Roboto Condensed"),
       height_svg = 5,
       options = list(
         opts_toolbar(saveaspng = FALSE))
)

Screenshot from laptop: laptop_screenshot

Screenshot from mobile device: mobile_screenshot

bwiernik commented 2 years ago

Install the latest version of gridtext from https://github.com/wilkelab/gridtext. It should be on CRAN soon.