Closed krassowski closed 4 years ago
The same happens with 9px
(10px
works perfectly)
I guess that the regular expression in clauswilke/gridtext/parse-css.R should be more like:
pattern <- "^((-?\\d+(\\.\\d+)?)(%|[a-zA-Z]+)|(0))$"
, rather than:pattern <- "^((-?\\d+\\.?\\d+)(%|[a-zA-Z]+)|(0))$"
Hope this helps!
(not 100% sure how to define a non-capturing group here and if this is valid syntax in R regexp)
Thanks for reporting. I'll fix this. You're correct the regular expression is wrong. In the mean time, you can write 9.0pt
.
library(ggplot2)
library(ggtext)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point(size = 3) +
scale_color_manual(
name = NULL,
values = c(setosa = "#0072B2", virginica = "#009E73", versicolor = "#D55E00"),
labels = c(
setosa = "<i style='color:#0072B2'>I. setosa</i>",
virginica = "<i style='color:#009E73'>I. virginica</i>",
versicolor = "<i style='color:#D55E00'>I. versicolor</i>")
) +
labs(
title = "**Fisher's *Iris* dataset**
<span style='font-size:9.0pt'>Sepal width vs. sepal length for three *Iris*
species</span>",
x = "Sepal length (cm)", y = "Sepal width (cm)"
) +
theme_minimal() +
theme(
plot.title = element_markdown(lineheight = 1.1),
legend.text = element_markdown(size = 11)
)
Created on 2019-11-26 by the reprex package (v0.3.0)
This should work now. Please install the latest version of gridtext and test.
Works indeed - thank you!
First, many thanks for this awesome package - no more dreadful struggles with plotmath!
Not sure if this is intended, or just a bug but setting font-size lower than 10pt results in an error, e.g.:
Error: The string '9pt' does not represent a valid CSS unit.
. I think that it would be nice to allow values less than 10 points. I've just installed from GitHub master with devtools, R 3.6.1.