我正在尝试将小写希腊符号 delta 和 permille 添加到 Quarto 中 ggplot2 中的轴标签,然后完整地编织为 PDF。内联结果看起来不错,但当采用 PDF 格式时,千分位显示为省略号 (...)。我使用的是在 YAML 中指定的 Arial Unicode MS 字体。这是我的基本代码,使用 permille 符号和 unicode 作为测试:
sia_data_plot <- read_excel("~/filepath/doc.xlsx")
sia_data_plot <- dplyr::filter(sia_data_plot, d13C < max(d13C))
sia_data_plot <- dplyr::filter(sia_data_plot, d15N < max(d15N))
sia_month_facet <- sia_data_plot
sia_month_facet <- ggplot(data = sia_data_plot, aes(x = d13C, y = d15N)) +
geom_point(aes(color = Tissue, shape = Transect), size = 3) +
facet_wrap(~Month) +
facet_wrap(~factor(Month, levels=c('March', 'June', 'August', 'October'))) +
scale_colour_brewer(type = "seq", palette = "Dark2") +
ggtitle("Isotopic composition biplot by month") +
labs(x = expression(paste(delta^15 * "N (‰)")), y = expression(delta^15 * "N (\u2030)")) +
theme_grey()
print(sia_month_facet)
您可以使用
bquote
代替表达式,它将在 pdf 输出中呈现良好的效果
library(palmerpenguins)
library(tidyverse)
options(tidyverse.quiet = TRUE)
plot_dat = penguins |>
mutate(sqr_body_mass = body_mass_g^2,
sqr_bill_depth = bill_depth_mm^2)
ggplot(plot_dat, aes(x = sqr_bill_depth, y = sqr_body_mass, color = species)) +
geom_point() +
geom_smooth() +
labs(x = bquote(delta^15 * "N(%)"), y = bquote(log(delta)^2))