Closed alewh2o closed 3 years ago
Since you're de-facto writing html, > and < signs need to be encoded with >
and <
.
library(ggplot2)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggtext)
library(RColorBrewer)
df = mtcars
# Labels with
labs = c("Within Budget",
">0,<br><3 months",
"<50 m<sup>3</sup>,<br>≥3 months"
)
my.pal = brewer.pal(3,"Set1")
p = ggplot(df, aes(x=hp, y=mpg, color = factor(gear))) +
geom_point(stat="identity") +
scale_color_manual(values = my.pal,
aesthetics = "color",
labels = labs) +
theme(legend.position = "bottom",
legend.text = element_markdown(size=8)
)
p
Created on 2020-09-13 by the reprex package (v0.3.0)
Hi Claus, thank you for pointing that out. It was an awfully simple mistake. Best regards.
I am also running into this issue with the following reprex:
library(ggplot2)
library(ggtext)
data <- data.frame(x = c(1:1000), y = c(1:1000))
data %>%
ggplot(aes(x, y)) +
geom_point() +
geom_richtext(aes(y = y, label = format(y, big.mark = ",")))
Some observations:
Howdy,
The package ggtext is wonderful for simplifying labels in ggplot using element_markdown. It was working fine about a week ago, but it is now giving the following error message:
Error: gridtext has encountered a tag that isn't supported yet: