在 ggsurvplot 中显示大于号(unicode 错误)
Displaying greater than sign in ggsurvplot (unicode errrors)
我正试图在我的 ggsurvplot
对象的分层标签中显示大于号。我在不同的情节中生成了类似的东西(下图):
上图中的功能代码
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")))
通常,我在显示 >
字符串时没有问题。但是,当我尝试使用 ">"
of ">1 Prior Progressions"
作为标签时,我不断遇到以下警告和错误代码:
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.
下面是我的导致错误的代码的 t运行 示例。
有错误的代码
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")))
但是,当我用 unicode 和字符串的组合替换 legend.labs
向量时,我能够 运行 编码,这使我得出结论 >
导致了错误。我通常使用这个网站快速搜索 unicode 并找到 >
符号的 unicode:https://www.compart.com/en/unicode/U+003E
然而,这个 unicode 似乎对应了错误的符号。代码 运行s 没有任何错误(只有以下警告 x6:Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database
)。产生错误符号的图像和代码如下:
符号不正确的代码
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")))
是否有任何解决方法可以使 >
正常显示?我真的不想只使用文字,因为我在其余的情节中使用了符号,它看起来会格格不入。如果 KM fit 对象的代表有帮助,我可以提供。谢谢!
根据@JosefZ 的建议,我使用了右箭头 unicode 来生成并且效果很好。包含解决方案的最终代码如下:
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"))
我正试图在我的 ggsurvplot
对象的分层标签中显示大于号。我在不同的情节中生成了类似的东西(下图):
上图中的功能代码
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")))
通常,我在显示 >
字符串时没有问题。但是,当我尝试使用 ">"
of ">1 Prior Progressions"
作为标签时,我不断遇到以下警告和错误代码:
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.
下面是我的导致错误的代码的 t运行 示例。
有错误的代码
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")))
但是,当我用 unicode 和字符串的组合替换 legend.labs
向量时,我能够 运行 编码,这使我得出结论 >
导致了错误。我通常使用这个网站快速搜索 unicode 并找到 >
符号的 unicode:https://www.compart.com/en/unicode/U+003E
然而,这个 unicode 似乎对应了错误的符号。代码 运行s 没有任何错误(只有以下警告 x6:Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font family not found in Windows font database
)。产生错误符号的图像和代码如下:
符号不正确的代码
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")))
是否有任何解决方法可以使 >
正常显示?我真的不想只使用文字,因为我在其余的情节中使用了符号,它看起来会格格不入。如果 KM fit 对象的代表有帮助,我可以提供。谢谢!
根据@JosefZ 的建议,我使用了右箭头 unicode 来生成并且效果很好。包含解决方案的最终代码如下:
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"))