Questions tagged [ggsave]

Use when asking a question related to saving a ggplot2 object. Part of ggplot2 package. ggsave is a convenient function for saving a plot. It defaults to saving the last plot that you displayed, using the size of the current graphics device. It also guesses the type of graphics device from the extension.

97 questions
31
votes
1 answer

Extrafont and ggsave: Characters end up on top of another

I'm currently trying to use Arial.ttf in all my plots. I have found several manuals about fonts online, I'm however running into issues when I try to save the pot via ggsave and the default device. Minimal working example I'm running the following…
ChrisK
  • 1,216
  • 8
  • 22
28
votes
5 answers

R ggplot, remove white margins in ggsave/ggplot

How can I remove the white margins in ggsave? My question is exactly the same as Remove white space (i.e., margins) ggplot2 in R. However, the answer there isn't ideal for me. Instead of trial and error for a fixed but unknown aspect ratio, I would…
jf328
  • 6,841
  • 10
  • 58
  • 82
13
votes
2 answers

Saving a graph with ggsave after using ggplot_build and ggplot_gtable

I am modifying a graph built with ggplot by altering the data produced by ggplot_build (for a reason similar to Include space for missing factor level used in fill aesthetics in geom_boxplot). As far as I understand the help I found on this topic, I…
Don't panic
  • 303
  • 1
  • 2
  • 10
7
votes
1 answer

`ggsave` jpg reversed black-white values with `theme_minimal()`

When I save a ggplot image with theme_minimal the black and white values are reversed in a photo negative like effect. This does not occur if I do not use a theme nor does it occur with theme_bw. It also does not occur when saving to .pdf or .png. I…
Lief Esbenshade
  • 793
  • 4
  • 13
7
votes
2 answers

Error while plotting with ggsave and other save functions

I have a problem concerning the function ggsave() and I would be really grateful for any help and or suggestions/solutions. I am creating four plots and put them all in one big plot, and since I want to loop the whole function using all columns in…
tony13s
  • 141
  • 1
  • 1
  • 6
5
votes
1 answer

ggsave Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "c('ggsurvplot', 'ggsurv', 'list')"

So I made a ggplot using a survifit curve. Wolcurves <- survfit(Surv(Days, Survival) ~ Wol, data = DCV_noPBS) IFB_plot <- ggsurvplot(Wolcurves, data = DCV_noPBS, line = c(2, 1), pval = "p-value = 0", …
AngeLeek
  • 51
  • 2
4
votes
4 answers

Save plot exactly as previewed in the "Plots" panel

I know that a very similar question already exists here, but the provided answer did not work for me. This is my usual workflow: I generate a plot and adjust the size of the plot in the "Plots" Panel of RStudio until I am satisfied. I then call…
nhaus
  • 786
  • 3
  • 13
4
votes
1 answer

how to ggsave rotated plots

I try to save plots with different angles (want to use it later for an animation in beamer). I tried this: data=data.frame(x=rnorm(100)) # creates the data plot <- ggplot2::qplot(x, data=data, geom="histogram") # create a histogram for(i in…
4
votes
0 answers

ggsave into clipboard on Windows

I'd like to ggsave a plot into my clipboard without leaving RStudio, on Windows. Something similar has been asked about for base R graphics, but I'd like to use ggplot+ggsave. example plot operation: library(tidyverse) { ggplot(data = mtcars,…
lost
  • 1,483
  • 1
  • 11
  • 19
3
votes
1 answer

Breaking change in ggsave() in 3.3.6 update: cannot reproduce old plots

The problem I have some code that creates a map with numerous points, annotated with some stats, on a monthly basis. This worked fine until I updated ggplot2 to 3.3.6, after which the plots have broken and I've not been able to figure out the…
3
votes
1 answer

Problems with labs(caption =... in ggplot as well as in ggsave - error "Error in titleGrob"

I am having a very strange problem with my ggplot2 where I am trying to save a graph as a png using ggsave that contains a caption in the labs parameter. When I used a standard example posted on the web to use as a test and simple post to replicate…
3
votes
2 answers

+r +ggplot +jpeg +backgroud +transparent

I'm trying to create a jpeg of a plot with a transparent background. I want to use the jpeg in powerpoint. I cannot get the transparency to work. When I insert the jpeg into a ppt, it still has a white background. Are there options I am…
Rich
  • 31
  • 1
2
votes
1 answer

Save last displayed plot (like or using ggsave)

Explanation Using ggplot2 and ggsave it is possible to save the last displayed plot: ggplot(data = data.frame(x = 1:10, y = 1:10), aes(x = x, y = y)) + geom_point() ggsave(filename = 'test.png', …
user1
  • 404
  • 1
  • 5
  • 18
2
votes
2 answers

Creating multiple plots within a loop and saving in R?

I am having trouble saving multiple plots from the output of a loop. To give some background: I have multiple data frames, each with the data for single chemical toxicity for multiple species. I have labelled each data frame for the chemical that it…
meistyad
  • 21
  • 1
2
votes
0 answers

Problem Saving Large SVG Images from ggplot (lost plot elements)

I am generating facetted plots (ggplot / ggsave) as SVG files for use in a WORD (Office 365, Windows 10) document that will be converted to a PDF. As a workaround for a limitation in WORD I wish to increase the SVG dimensions by a factor of 10 (for…
AWaddington
  • 725
  • 8
  • 18
1
2 3 4 5 6 7