我尝试使用ggplot2绘制一个带有中文标题的图表,但在一个正方形中显示了Unicode。
我尝试了以下命令
quartz(family='STKaiti')
par(family='STKaiti')
plot(1, xlab = "你好", family = "Heiti SC Light")并使用"extrafont“字体将我的ubuntu字体加载到R中

绘图显示的字符仍然是方块中的Unicode。我想正确地展示这个中文单词。
尽管如此,我还是不知道怎么叫这种词。“方块中的Unicode”是我能描述的最好的描述。
发布于 2019-04-27 05:42:00
试试showtext包,它就是为此而设计的。
示例代码:
library(ggplot2)
library(showtext)
showtext_auto()
p = ggplot(NULL, aes(x = 1, y = 1)) + ylim(0.8, 1.2) +
annotate("text", 1, 1, size = 15, label = "你好,世界") +
xlab("坐标轴") +
theme_bw(base_family = "wqy-microhei", base_size = 24)
quartz()
print(p)

https://stackoverflow.com/questions/55702377
复制相似问题