R: ggplot2からpostscript出力 [統計]
わけあってggplot2からpostscript出力。ちょっと手間がかかる。
n <- 100 x <- rnorm(n, 0, 1) y <- rnorm(n, 0, 1) z <- sqrt(x^2 + y^2) library(ggplot2) postscript(family = "Japan1GothicBBB", onefile = FALSE, width = 12 / 2.54, height = 9 / 2.54, paper = "special", horizontal = FALSE) df <- data.frame(x = x, y = y, z = z) p <- ggplot(df) + geom_point(aes(x = x, y = y, colour = z), size = 3) + coord_fixed(ratio = 1) + scale_colour_gradient(name = "Zの値", low = "grey90", high = "grey10") + xlab("Xの値") + ylab("Yの値") + theme_bw(base_family = "") %+replace% theme(legend.title = element_text(face = "plain")) print(p) dev.off()
themeのlegend.titleでfaceを"plain"にしておかないと、この部分がばける。 ghostscriptでは、GothicBBB-Medium-Bold-EUC-Hがみつからないというエラーになるが、Adobe DistillerではCourierに置換してくれる。
タグ:R
コメント 0