survminer
survminer copied to clipboard
Ability to use plot math in legend text { Feature Request}
Expected behavior
If using expression( x^2 ~ y^2) as one argument in ggsurvplot(..., legend.labs = c(expression(x^2 ~ y^2)), ..)) It will be shown as $x^2$ $y^2$ and not as x^2 ~ y^2 on the plot.
Actual behavior
This normally works in ggplot by using the scale_colour_xx() argument but this also doesn't work as the + operator doesn't work for ggsurv objects. and you can't insert scale_colour_xx into the ggsurvplot() call.
Steps to reproduce the problem
My code both for standard ggplot and for ggsurvplot library(ggplot2) library(survival) library(survminer) data <- iris p <- ggplot(data = data, aes(Petal.Length,Petal.Width, colour = Species)) p +geom_point() + scale_color_discrete(labels = (c(expression(degree*C),'abc','asp'))) d <- lung d$Survobj <-with(d,Surv(d$time, event = d$status)) km <-survfit(Survobj ~sex, data = d) ggsurvplot(km, data = d, legend.labs = c(expression(x^2 ~y^2),'abc')) ggsurvplot(km, data = d, scale_color_continuous(labels = c(expression(x^2 ~y^2),'abc'))) p2 <- ggsurvplot(km, data = d) p2 + scale_color_continuous(labels = c(expression(x^2 ~y^2),'abc'))
session_info()
Session info ----------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, mingw32
ui RStudio (1.1.456)
language (EN)
collate Danish_Denmark.1252
tz Europe/Paris
date 2018-11-11
Packages --------------------------------------------------------------------------
package * version date source
assertthat 0.2.0 2017-04-11 CRAN (R 3.5.1)
backports 1.1.2 2017-12-13 CRAN (R 3.5.0)
base * 3.5.1 2018-07-02 local
bindr 0.1.1 2018-03-13 CRAN (R 3.5.1)
bindrcpp 0.2.2 2018-03-29 CRAN (R 3.5.1)
broom 0.5.0 2018-07-17 CRAN (R 3.5.1)
cmprsk 2.2-7 2014-06-17 CRAN (R 3.5.1)
colorspace 1.3-2 2016-12-14 CRAN (R 3.5.1)
compiler 3.5.1 2018-07-02 local
crayon 1.3.4 2017-09-16 CRAN (R 3.5.1)
data.table 1.11.4 2018-05-27 CRAN (R 3.5.1)
datasets * 3.5.1 2018-07-02 local
devtools 1.13.6 2018-06-27 CRAN (R 3.5.1)
digest 0.6.17 2018-09-12 CRAN (R 3.5.1)
dplyr 0.7.6 2018-06-29 CRAN (R 3.5.1)
ggplot2 * 3.0.0 2018-07-03 CRAN (R 3.5.1)
ggpubr * 0.1.8 2018-08-30 CRAN (R 3.5.1)
glue 1.3.0 2018-07-17 CRAN (R 3.5.1)
graphics * 3.5.1 2018-07-02 local
grDevices * 3.5.1 2018-07-02 local
grid 3.5.1 2018-07-02 local
gridExtra 2.3 2017-09-09 CRAN (R 3.5.1)
gtable 0.2.0 2016-02-26 CRAN (R 3.5.1)
km.ci 0.5-2 2009-08-30 CRAN (R 3.5.1)
KMsurv 0.1-5 2012-12-03 CRAN (R 3.5.0)
knitr 1.20 2018-02-20 CRAN (R 3.5.1)
labeling 0.3 2014-08-23 CRAN (R 3.5.0)
lattice 0.20-35 2017-03-25 CRAN (R 3.5.1)
lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.1)
magrittr * 1.5 2014-11-22 CRAN (R 3.5.1)
Matrix 1.2-14 2018-04-13 CRAN (R 3.5.1)
memoise 1.1.0 2017-04-21 CRAN (R 3.5.1)
methods * 3.5.1 2018-07-02 local
munsell 0.5.0 2018-06-12 CRAN (R 3.5.1)
nlme 3.1-137 2018-04-07 CRAN (R 3.5.1)
pillar 1.3.0 2018-07-14 CRAN (R 3.5.1)
pkgconfig 2.0.2 2018-08-16 CRAN (R 3.5.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.5.1)
purrr 0.2.5 2018-05-29 CRAN (R 3.5.1)
R6 2.2.2 2017-06-17 CRAN (R 3.5.1)
Rcpp 0.12.18 2018-07-23 CRAN (R 3.5.1)
rlang 0.2.2 2018-08-16 CRAN (R 3.5.1)
rstudioapi 0.7 2017-09-07 CRAN (R 3.5.1)
scales 1.0.0 2018-08-09 CRAN (R 3.5.1)
splines 3.5.1 2018-07-02 local
stats * 3.5.1 2018-07-02 local
survival * 2.42-3 2018-04-16 CRAN (R 3.5.1)
survminer * 0.4.3 2018-08-04 CRAN (R 3.5.1)
survMisc 0.5.5 2018-07-05 CRAN (R 3.5.1)
tibble 1.4.2 2018-01-22 CRAN (R 3.5.1)
tidyr 0.8.1 2018-05-18 CRAN (R 3.5.1)
tidyselect 0.2.4 2018-02-26 CRAN (R 3.5.1)
tools 3.5.1 2018-07-02 local
utils * 3.5.1 2018-07-02 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.1)
xtable 1.8-3 2018-08-29 CRAN (R 3.5.1)
yaml 2.2.0 2018-07-25 CRAN (R 3.5.1)
zoo 1.8-3 2018-07-16 CRAN (R 3.5.1)
Any help with getting symbols in the legend would be appreciated
Agree, this is an essential feature. I would also appreciate it to be part of the next versions. Thanks.
Agree too, I need the superscript feature when dealing with my own data. I would also appreciate it to be part of the next versions. Thanks a lot.
I have a similar issue when trying to use the expression for having italics in part of the legend lab names.
any fix to this yet?