Last active
May 24, 2018 06:38
-
-
Save whatalnk/1e5f732aabe240514843d5034d99bfe5 to your computer and use it in GitHub Desktop.
[R] cairo_pdf or Cairo::CairoPDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r} | |
library(ggplot2) | |
library(Cairo) | |
``` | |
```{r} | |
gp <- ggplot(cars, aes(x=speed, y=dist)) + | |
geom_point() | |
gp | |
``` | |
`cairo_pdf` | |
```{r} | |
ggsave(filename = "plot-cars-cairo_pdf.pdf", plot=gp, width=8, height=6, device=cairo_pdf, units = "in") | |
``` | |
`CairoPDF` | |
```{r} | |
library(Cairo) | |
``` | |
```{r} | |
CairoPDF(file="plot-cars-CairoPDF", width=8, height=6) | |
gp | |
dev.off() | |
``` | |
```{r} | |
windowsFonts(`IPAexGothic` = windowsFont("IPAexゴシック")) | |
gp_ja <- ggplot(cars, aes(x=speed, y=dist)) + | |
geom_point() + | |
xlab("スピード") + ylab("停止距離") + | |
theme_bw(base_family = "IPAexGothic") | |
gp_ja | |
``` | |
`cairo_pdf` | |
```{r} | |
ggsave(filename = "plot-cars-ja-cairo_pdf.pdf", plot=gp_ja, width=8, height=6, device=cairo_pdf, units = "in") | |
``` | |
`Cairo::CairoPDF` | |
```{r} | |
CairoPDF(file="plot-cars-ja-CairoPDF", width=8, height=6) | |
gp_ja | |
dev.off() | |
``` | |
普通の pdf | |
フォント埋め込みされず,日本語フォントを指定するとエラー | |
```{r} | |
ggsave(filename = "plot-cars-pdf.pdf", plot=gp, width=8, height=6, device=pdf, units = "in") | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment