I am attempting to display a greater than sign in my strata labels for a ggsurvplot
object. I generated something similar in a different plot (image below):
Functioning Code from Image Above
kmcurve_spd <- ggsurvplot(km_fitp1_spd,
palette = c("#202960", "#8CC63E", "#5B9BD5", "#8f94af"),
xlab = "Time (Months)",
legend.labs = c(paste0("<500 mm","\u00b2"), paste0("\u2265","500",
" or <1000 mm","\u00b2"), paste0("\u2265", "1000 or <1500 mm","\u00b2"),
paste0("\u2265","1500 mm\u00b2")))
Normally, I do not have a problem displaying >
sign in a character string. However, when I try to use ">"
of ">1 Prior Progressions"
as a label, I keep encountering the following warning and error codes:
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Error: gridtext has encountered a tag that isn't supported yet: <blockquote>
Only a very limited number of tags are currently supported.
Below is a truncated sample of my code that is causing the error.
Code with Error
kmcurve_pd <- ggsurvplot(km_fitp1_pd,
palette = c("#202960", "#8CC63E"),
xlab = "Time (Months)",
legend.labs = c(paste0("\u2265","1 Prior Progression"), ">1 Prior Progression"))
#this also generates the same error
kmcurve_pd <- ggsurvplot(km_fitp1_pd,
palette = c("#202960", "#8CC63E"),
xlab = "Time (Months)",
legend.labs = c(paste0("\u2265","1 Prior Progression"),
paste0(">","1 Prior Progression")))
However, I was able to run code when I replace the legend.labs
vector with a combination of unicode and character strings, leading me to the conclusion the >
is causing the error. I usually use this website to quickly search unicodes and located the unicode for the >
sign: https://www.compart.com/en/unicode/U+003E
This unicode, however, seems to correspond to the wrong symbol. The code runs without any errors (only the following warning x6: Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database
). Image of and code producing the incorrect symbol is below:
Code with Incorrect Symbol
kmcurve_pd <- ggsurvplot(km_fitp1_pd,
palette = c("#202960", "#8CC63E"),
xlab = "Time (Months)",
legend.labs = c(paste0("\u2264","1 Prior Progression"), paste0("\u00e3",
"1 Prior Progression")))
Are there any workarounds so that I can get the >
to display properly? I really don't want to use just words, as I have used symbols for the rest of my plots and it will look out of place. If a reprex of the KM fit object would be helpful, I can provide. Thanks!
Per @JosefZ's suggestion, I utilized the right arrowhead unicode to generate and it worked great. Final code with solution incorporated is below:
kmcurve_pd <- ggsurvplot(km_fitp1_pd,
palette = c("#202960", "#8CC63E"),
xlab = "Time (Months)",
legend.labs = c(paste0("\u2264","1 Prior Progression"),
paste0("\u02C3","1 Prior Progression"))