LoginSignup
14
15

More than 5 years have passed since last update.

png/jpgなどにplotする際に適切に日本語文字列を描画する

Posted at

Mac + Rの環境でplotする時には.Rprofileでフォントの指定をするのが定番になっている(例: Mac OSXのRで日本語をプロットしたい - 驚異のアニヲタ社会復帰への道).
しかし,これだけでは

png("/tmp/test.png")
plot(iris, main = "アヤメのデータ")
dev.off()

とした場合にmain部分が文字化けする.
これを回避するには

png("/tmp/test.png")
par(family="HiraMaruProN-W4")
plot(iris, main = "アヤメのデータ")
dev.off()

とかやってフォントを指定すれば適切に描画される.

14
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
15