You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除ggplot中Unicode符号周围的方框

在ggplot折线图末端添加符号时出现方框问题

我之前在Stack Overflow提问过如何用ggplot的geom_line在折线图末端添加符号,问题已经得到解答,但现在不管用自己的方案还是@Stibu提供的代码,符号周围都会出现方框。这个问题无法复现,我已经多次更新包、重启R会话,还是得不到期望效果。

问题效果

问题效果

期望效果

期望效果

我的数据集

structure(list(id = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 
5L, 5L, 5L, 5L, 6L, 6L, 7L, 7L, 7L, 7L, 8L, 9L, 9L, 9L, 10L, 
10L, 10L, 11L, 11L, 11L, 11L, 12L, 12L, 13L, 13L, 14L, 14L, 15L, 
16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 20L, 21L, 21L, 21L, 
22L, 23L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 27L, 28L, 28L, 
29L, 29L, 29L, 30L), levels = c("1", "2", "3", "4", "5", "6", 
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", 
"18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", 
"29", "30"), class = "factor"), time_point = structure(c(1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 3L, 4L, 1L, 2L, 1L, 2L, 3L, 
4L, 1L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 4L, 1L, 2L, 1L, 2L, 
1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 3L, 1L, 2L, 3L, 
1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 3L, 
1L), levels = c("0", "24", "48", "72"), class = "factor"), avg_rag = c(257600, 
11653000, 161100, 295303000, 151300, 6288000, 319800, 67233000, 
190000, 3326000, 4050900, 97663200, 233900, 10203000, 253100, 
325400, 2438700, 24111900, 405300, 319400, 1598100, 17572700, 
370900, 2510100, 143632700, 323900, 2521100, 3371700, 18591900, 
468600, 92084100, 317700, 155815100, 228200, 26215100, 260500, 
270400, 302800, 156915100, 104400, 172215100, 80900, 133516700, 
167800, 4845700, 22993100, 146900, 2938700, 19033100, 100500, 
47300, 134416700, 169400, 17296700, 62500, 929600, 68800, 1251600, 
265000, 1956600, 193700, 946600, 153100, 1032600, 15145000, 134300
), log_avgroi = c(5.41094585868777, 7.06643774645399, 5.20709554041922, 
8.47026785900987, 5.17983892802319, 6.79851253303135, 5.50487845941022, 
7.8275824903173, 5.27875360095283, 6.5219222448835, 6.6075515223778, 
7.9897309501301, 5.36903022180915, 7.00872788665238, 5.40329214515825, 
5.51241754860084, 6.38715837827271, 7.38223143381187, 5.60777660374169, 
5.50433491180246, 6.20360395150449, 7.24483849484836, 5.56925683332861, 
6.39969102370537, 8.15725332439694, 5.51041094801018, 6.40159007240666, 
6.52784892593472, 7.26932377478269, 5.67080228426094, 7.96418464780391, 
5.50201721482715, 8.19260954273903, 5.3583156400822, 7.41855151871064, 
5.41580772763554, 5.4320066872696, 5.48115587082803, 8.19566473792177, 
5.01870049866624, 8.23607122818133, 4.90794852161227, 8.12553558977738, 
5.22479195649268, 6.68535652321923, 7.36159752812586, 5.16702179579026, 
6.46815525296793, 7.27950952939307, 5.00216606175651, 4.67486114073781, 
8.12845322903989, 5.22891340599469, 7.23796325292663, 4.79588001734407, 
5.96829611504626, 4.83758843823551, 6.09746555447416, 5.42324587393681, 
6.2915020491896, 5.28712962071911, 5.97616650013198, 5.18497519069826, 
6.0139321207112, 7.18026927766887, 5.12807601266872)), row.names = c(NA, 
-66L), class = c("tbl_df", "tbl", "data.frame")) 

我目前的实现代码

# slice for last point
longer_last <- longer_t1 %>%
  group_by(id) %>%
  slice(which.max(time_point))

# graph
library("scales")

ggplot(
  longer_t1,
  aes(x = time_point, y = avg_rag, group = id, colour = id)
) +
  geom_line(linewidth = 1) +
  scale_y_continuous(
    name = "average radiance (p/sec/cm²/sr)",
    breaks = pretty_breaks(),
  ) +
  scale_x_discrete(name = "time in h") +
  theme_classic() +
  geom_point(
    data = longer_last,
    aes(y = avg_rag, x = time_point),
    shape = "✝",
    size = 5,
    position = position_nudge(x = 0.07),
    stroke = 0
  ) +
  scale_color_discrete(name = "")

内容的提问来源于stack exchange,提问作者mr.raccoon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 16:52:00