-
Notifications
You must be signed in to change notification settings - Fork 0
/
ggtiksave.R
executable file
·31 lines (26 loc) · 1.03 KB
/
ggtiksave.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# EXPORT GGPLOTS TO TIKZ
require(tikzDevice)
require(ggplot2)
ggtiksave <- function(filename,
plot_to_store = last_plot(),
width = 5,
height = 3.5,
plot.title.textsize.rel = 1,
plot.title.textsize.vjust = 0,
axis.title.textsize.rel = .8,
axis.title.y.textsize.vjust = 2,
axis.title.x.textsize.vjust = -0.5){
# Create tikz file
tikz(file = filename, height = height, width = width)
# add correction parameters to labels
plot_to_store <- plot_to_store +
theme(plot.title = element_text(size = rel(plot.title.textsize.rel),
vjust = plot.title.textsize.vjust),
axis.title = element_text(size = rel(axis.title.textsize.rel)),
axis.title.y = element_text(vjust = axis.title.y.textsize.vjust),
axis.title.x = element_text(vjust = axis.title.x.textsize.vjust))
# write plot to file
print(plot_to_store)
# close device and save file
dev.off()
}