plotRTeX-package: ggplot2 to PDF in LaTeX Format

Description Details Author(s) See Also Examples

Description

ggplot2 graphics to PDF using LaTeX Converts ggplot2 graphics to PDF using LaTeX. Relies on tikzDevice to create a tikzpicture and then compiles a LaTeX standalone document using PDFLaTeX.

Details

This package was not yet installed at build time.

Index: This package was not yet installed at build time.
Converts ggplot2 graphics to graphic in LaTeX (tikzpicture) using tikzDevice. Then, compile to a LaTeX standalone document.

Author(s)

Ewen Gallic

Maintainer: Ewen Gallic <ewen.gallic@gmail.com>

See Also

tikz

Examples

 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
economics_long <- 
mutate(economics_long, variable_tex = factor(variable,
                        levels = c("pce", "pop", "psavert", "uempmed", "unemploy"),
                        labels = c("$PCE_t$", "$N_t$", "$r_t$", "$\bar{s}_t$", "$s_t$")))



p <- 
  ggplot(economics_long, aes(x = date, y = value01, colour = variable_tex, linetype = variable_tex)) +
  geom_line(size = 2) +
  scale_colour_discrete("Variable") +
  scale_linetype_discrete("Variable") +
  xlab("") + ylab("") +
  theme(text = element_text(size = 20),
        panel.background = element_rect(fill = NA),
        panel.spacing = unit(1, "lines"),
        panel.grid.major = element_line(colour = "grey90"),
        panel.grid.minor = element_blank(),
        plot.title = element_text(hjust = 0, size = rel(1.3), face = "bold"),
        plot.margin = unit(c(1, 1, 1, 1), "lines"),
        # Axes
        axis.line = element_line(colour = "grey60"),
        axis.text = element_text(colour = "#7F7F7F"),
        axis.title = element_text(),
        # Legende
        legend.text = element_text(size = rel(1.1)),
        legend.title = element_text(size = rel(1.1)),
        legend.key = element_rect(fill = NA),
        legend.key.size = unit(2, "lines"),
        legend.key.width = unit(2.5, "lines"),
        legend.position = "right", 
        legend.box = "vertical",
        legend.direction = "vertical",
        # Faceting
        strip.background = element_rect(fill=NA, colour = NA),
        strip.text = element_text(size = rel(1.1))
  )
  
# ggplot2_to_pdf(plot = p, path = "./", filename = "eco", width = 15, height = 8)

# Using facetting

p_2 <- 
  ggplot(economics_long, aes(x = date, y = value01, colour = variable_tex, linetype = variable_tex)) +
  facet_wrap(~variable_tex) +
  geom_line(size = 2) +
  scale_colour_discrete("Variable") +
  scale_linetype_discrete("Variable") +
  xlab("") + ylab("") +
  theme(text = element_text(size = 20),
        panel.background = element_rect(fill = NA),
        panel.spacing = unit(1, "lines"),
        panel.grid.major = element_line(colour = "grey90"),
        panel.grid.minor = element_blank(),
        plot.title = element_text(hjust = 0, size = rel(1.3), face = "bold"),
        plot.margin = unit(c(1, 1, 1, 1), "lines"),
        # Axes
        axis.line = element_line(colour = "grey60"),
        axis.text = element_text(colour = "#7F7F7F"),
        axis.title = element_text(),
        # Legende
        legend.text = element_text(size = rel(1.1)),
        legend.title = element_text(size = rel(1.1)),
        legend.key = element_rect(fill = NA),
        legend.key.size = unit(2, "lines"),
        legend.key.width = unit(2.5, "lines"),
        legend.position = "bottom", 
        legend.box = "vertical",
        legend.direction = "horizontal",
        # Faceting
        strip.background = element_rect(fill=NA, colour = NA),
        strip.text = element_text(size = rel(1.1))
  )


# ggplot2_to_pdf(plot = p_2, path = "./", filename = "eco_faceting", width = 15, height = 8)

3wen/plotRTeX documentation built on April 13, 2020, 11:43 p.m.