tidyverse / tidyverse/ggplot2

ggtext and parsing html with latest version of ggplot

Open
#6,752 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

themes :dancer:
Dominant language
R
Stars
7k
Forks
2.1k
Avg merge
59m
Merged PRs (30d)
2

Description

I found a problem with ggplot and rendering html text with ggtext or marquee

I expected to parse character string in html format and have the style implemented.
This works for my code in ggplot 3.5.2 but not in ggplot 4.0.0

Here is the code to reproduce the bug:

library(ggplot2)
library(ggtext)

# Minimal dataframe
df <- data.frame(
  gRNA_type = rep(c("cd<sup><i>g338-384</i></sup>", 
                    "wt<sup><i>control</i></sup>"), each = 5),
  win = c(95, 88, 92, 90, 94, 45, 50, 48, 52, 47),
  loss = c(5, 12, 8, 10, 6, 55, 50, 52, 48, 53),
  id = 1:10
)

# Test plot
ggplot(df, aes(x = gRNA_type, y = win)) +
  geom_point() +
  theme_minimal() +
  theme(axis.text.x = element_markdown())

Created on 2025-11-19 with reprex v2.1.1

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided R reproduction with ggplot2, ggtext, and element_markdown(), then compare the behavior between ggplot2 3.5.2 and 4.0.0. No repository file or test is named in the issue; done means the HTML styling renders correctly in the affected ggplot2 version.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.