如何用日语创建ggplot2标题? [英] How can I create ggplot2 titles in Japanese?

查看:125
本文介绍了如何用日语创建ggplot2标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在准备日语演示文稿,希望我的图像的标题和图例名称使用日语.我可以在RStudio中很好地渲染文本,但是在渲染图像时,日语字符只是显示为方框.

I am preparing a presentation in Japanese and would like the titles and legend names of my images to be in Japanese. I can get the text to render just fine in RStudio but when the image is rendered the Japanese characters just appear as boxes.

x=-10:10
y=x*x
df=data.frame(x,y)
ggplot(df, aes(x,y)) + geom_line() + ggtitle("テスト")

谢谢.

推荐答案

似乎您正在执行类似操作.我使用的是Mac,最初没有看到您在ggplot图中指定的字母.但是以下代码正在打印字母.

It seems that you do something like this. I am using Mac, and I initially did not see the letters you specified in ggplot graph. But the following code is printing the letters.

theme_set(theme_gray(base_size=12, base_family="HiraKakuProN-W3"))

ggplot(df, aes(x,y)) + 
geom_line() +
ggtitle("テスト") 

这篇关于如何用日语创建ggplot2标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆