finalize_ggplot: Arrange alignment and save JOTA ggplot chart Running this...

Description Usage Arguments Value Examples

View source: R/finalize_ggplot.R

Description

Arrange alignment and save JOTA ggplot chart

Running this function will save your plot with the correct guidelines for publication for a BBC News graphic. It will left align your title, subtitle and source, add the JOTA logo at the bottom right and save it to your specified location.

Usage

1
2
3
4
5
6
7
8
finalize_ggplot(
  plot,
  source = "",
  save_filepath = file.path(Sys.getenv("TMPDIR"), "tmp-nc.png"),
  width_pixels = 640,
  height_pixels = 450,
  image_path = file.path(system.file("figs", package = "jotaR"), "jotalogo.png")
)

Arguments

plot

The variable name of the plot you have created that you want to format and save

source

The text you want to come after the text 'Source:' in the bottom left hand side of your side

save_filepath

Exact filepath that you want the plot to be saved to

width_pixels

Width in pixels that you want to save your chart to - defaults to 640

height_pixels

Height in pixels that you want to save your chart to - defaults to 450

image_path

File path for the logo image you want to use in the right hand side of your chart, which needs to be a PNG file - defaults to JOTA logo image that sits within the data folder of your package

Value

(Invisibly) an updated ggplot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
library(ggplot2)
data(Governismo)

p1 = ggplot(Governismo, aes(x=D1, y=D2)) +
 geom_point() +
 labs(x="IDEOLOGIA (D1)", y="POSICIONAMENTO ECONÔMICO (D2)",
      title="Um exemplo de scatterplot",
      subtitle="Apoio ao texto da Reforma: Threshold 80% a 20%") +
 theme_jota(grid=FALSE)


finalize_ggplot(plot = p1,
source = "https://jota.info",
# save_filepath = "filename_that_my_plot_should_be_saved_to-nc.png",
width_pixels = 640,
height_pixels = 450,
image_path = "image.png"
)
## End(Not run)

JOTAJornalismo/rJOTA documentation built on Oct. 2, 2020, 4:40 p.m.