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.
Questions tagged [ggsave]
97 questions
2
votes
0 answers
How to make sure the font stays the same when using ggsave
I'm trying to add multiple plots from ggplot into my Latex report. Most plots have different dimensions, as some need to be rectangle shaped, where as some need to be square shaped. To shape the plots, I've been changing the height and width…
user15077915
2
votes
1 answer
Encounter "Error: $ operator is invalid for atomic vectors" when using ggsave
Here's the code I prepare as an example. Everything was fine until I ran the ggsave. The error is about $ operator, which is quite confusing. I have seen many people who have similar error messages in different cases. Is it my fault or an internal R…

Miles N.
- 165
- 7
2
votes
1 answer
Exporting plot png using cairo
I generally have been exporting pngs of my plots, by using ggsave and setting type to cairo for antialiasing. However, recently I got this error:
Using ragg device as default. Ignoring `type` and `antialias` arguments
I'm not sure what I did or…

Justin
- 141
- 8
2
votes
1 answer
Unable to download a .png file from shiny
I'm trying to create a download button for my histogram plot. I have the download button visible, but can't seem to get it to download correctly. It always downloads a .htm file and not the .png file. I"m using the ggsave command in my server.R. …

TER
- 107
- 6
2
votes
0 answers
Cannot save ggplot with umlauts in expressions with cairo_pdf
I wanted to create a plot with ggplot and save it with ggsave(). As a device I used cairo_pdf, because I want to embed the font. The problem is that if the plot contains an umlaut I can create the plot fine in RStudio, but if I want to save it I get…

Gilean0709
- 1,098
- 6
- 17
2
votes
0 answers
ggsave mac .png ignores size
On my Macbook Pro, early 2015, running High Sierra (if that matters) - it appears as though ggsave ignores my image width and height specification for .png files. I do not have this problem on machines running Windows. Here's a little reproducible…

Kris Williams
- 122
- 6
1
vote
1 answer
How to save the plot as full screen with `ggsave`?
df_rate_flat <- structure(list(pair = c("0841_0851_Mandaic", "0843_0850_Mandaic", "0846_0855_Mandaic", "0849_0856_Mandaic", "084A_084D_Mandaic", "0853_0857_Mandaic", "10332_10338_Gothic", "10334_10340_Gothic", "10336_10348_Gothic",…

Julien
- 1,613
- 1
- 10
- 26
1
vote
0 answers
How can I adjust the width of bar plots with different numbers of columns for consistent presentation in Word?
I am currently trying of saving several plots to put them in my word document for presentation. Some bar plots have 4 columns, others have 8. I would like to adapt the size of the bar plots with only 4 or 5 columns, so that they are only have of the…

Laura Aina
- 11
- 1
1
vote
1 answer
How to avoid overlapp in geom_line
I have a really long and extended code, which I have created with graphs that shows lines overlapping.
Could you please suggest something to disentangle this and make the reproduction clearer? Maybe some other options to modify the size of graph…

12666727b9
- 1,133
- 1
- 8
- 22
1
vote
1 answer
Big change in computational time if I store the ggplot object before saving the plot
Please have a look at the reprex below.
Even on a very seasoned laptop, it takes about one minute to get the job done and save a large colored scatterplot as a png file using ggplot2.
What puzzles me is that if I change slightly the last part of the…

larry77
- 1,309
- 14
- 29
1
vote
1 answer
Kaplan Meier curve (with ggsurvplot) with transparent background
I made a Kaplan Meier curve with ggsurvplot as such:
kaplan_plot365d <- ggsurvplot(kmcurve365d,
conf.int = TRUE,
legend.labs = c('Trop-T normal and Trop-I normal', 'Trop-T elevated and Trop-I…

esptang
- 23
- 3
1
vote
1 answer
How to display a data group as points and another one as confidence ellipse? Issues with ggplot and ggsave
I am new to R, and I am trying to generate scatter plots with two variables, with the values of each variable grouped into 4 classes.
In particular, I am trying to achieve the following:
Display two groups as data points, two groups as confidence…

Pier Volc
- 13
- 3
1
vote
1 answer
Save multiple ggplot figures as the same scale using ggsave, despite x axis text having different lengths
I am trying to create a set of multiple figures that are the same scale. I have set the scale as the same for all figures, but when I save using ggsave, the figures save as different sizes because of the x-axis text lengths, making the scales not…

cgxytf
- 421
- 4
- 11
1
vote
6 answers
Is there a way to save multiple ggplots to a single PDF while using a for loop?
My current code:
library(pdftools)
plot <- NA
Indicator <- unique(map_and_data$Indicator)
plot<-list (1:length(Indicator))
for (i in 1 : length(Indicator))
{
df = map_and_data[map_and_data$Indicator==Indicator[[i]],]
plot[[i]]<- ggplot()+
…

I.R
- 11
- 4
1
vote
1 answer
I am at a loss - ggplot2::ggsave will not export custom fonts
I have spent my entire day today trying to sort this out. I have found tons of old posts with no actual solutions to this problem.
I have a custom font - it's loaded, it's installed, it appears when I look under font_families().
The font appears…

lucretiuss
- 75
- 1
- 7