資料
我試著通過這里的執行緒尋找答案,但據我所知,沒有一個是針對我的問題的。這是我的查詢的一些模擬資料。
#### Load Library ####
library(tidyverse)
#### Set Random Seed ####
set.seed(123)
#### Create Data ####
character <- c("哎","不","嗎","都","發",
"你","肉","吧","地","有")
x <- round(rnorm(n=10,
mean=10))
y <- round(rnorm(n=10,
mean=10))
#### Store Into Tibble ####
tib <- tibble(
character,
x,
y
)
問題
現在,如果我創建這個情節:
#### Plot ####
tib.plot <- tib %>%
ggplot(aes(x,y,
label=character))
geom_point()
geom_label()
geom_smooth(se=F)
labs(x="Some Variable",
y="Some Other Variable",
title = "Simulated Plot")
theme_classic()
tib.plot
在 R 的繪圖視窗中看起來像這樣:

但是,當我嘗試使用匯出功能保存繪圖時,由于某些解碼/編碼問題,它洗掉了漢字:

我該如何解決?
uj5u.com熱心網友回復:
如果您不介意您的文本將被矢量化,您可以使用pdf()and showtext:
library(showtext)
pdf('plot.pdf', width=8, height=5)
showtext_begin()
tib.plot
dev.off()

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/534803.html
