Cha*_*hao 1 r ggplot2 rstudio-server docker
我尝试使用 ggplot2 绘制带有中文标题的图表,但在正方形中显示 Unicode。
我已经尝试了一些以下命令
quartz(family='STKaiti')
par(family='STKaiti')
plot(1, xlab = "??", family = "Heiti SC Light")
Run Code Online (Sandbox Code Playgroud)
并使用“extrafont”字体将我的 ubuntu 字体加载到 R
字符图显示的仍然是正方形中的 Unicode。我想正确显示中文单词。
不过,我不知道如何称呼这种词。“正方形中的 Unicode”是我能描述的最好的。
试试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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1564 次 |
| 最近记录: |