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
0
votes
0 answers

R aborted when using ggsave with cairo_pdf

I recently updated R to version 4.1.1 on MacOS via Homebrew. Since then, everytime I tried to use ggsave with the cairo_pdf device like this on R-Studio: ggsave(plot = p, filename = plot_file, device = cairo_pdf, width = 8, height = 8) R then…
ibagur
  • 1
  • 2
0
votes
1 answer

Overlapping axis number labels when using 'device = "pdf"' in ggplot2

This solution seems to have died. It was answered 9 years and 10 months ago, by that time it is allowed to be replaced by several updates in between. Now, for an example I want to use the dput from this question (which is my data). My current…
PolII
  • 107
  • 8
0
votes
1 answer

Problem with the x-axis labels in ggplot2 using n.breaks

I use n.breaks to have a labeled x-axis mark for each cluster this works well for 4, 5, 6 clusters. Now I tried it with two cluster and it does not work anymore. I build the graphs like this: country_plot <- ggplot(Data) + aes(x = Cluster)…
Sese
  • 15
  • 3
0
votes
1 answer

Is there a way that I can solve or stop this error problem in cardinality_threshold?

I have about 17 soil variables that I'd like to run correlations with elevations, temperature and rainfall against species richness and abundance. I have 39 plots (rows) and the columns contain, environmental variables such as elevation, abundance,…
0
votes
0 answers

How to print superscript with annotation_custom or with other function in plots obtained from a loop in r

I want to print the expression and r squared; however the way to obtain the text of r squared isn't appropriate. I am working with a list or multiple linear models and with annotation_custom I got to locate the text without problems. Below there is…
0
votes
0 answers

How can I save a list of ggplot with unique file names?

That's my current code for saving a list of different ggplots: The problem is that it saves all the different plotnames (raphael_2021_022.png and raphael_2021_023.png - which I want!) but every unique png file contains always the same ggplot…
Raphael
  • 29
  • 5
0
votes
1 answer

Save plots generated by repeat function

Currently I am looking for a solution to save 72 plots to an PDF file. Those 72 plots are created through a function and the below code of repeat. The ID stands for a person within my dataset. This person has multiple rows of data attached to his…
Robbie Voort
  • 121
  • 6
0
votes
1 answer

R function with ggplot and ggsave saves empty file

I made a function that plots some data but I wanted to incorporate 'ggsave'. However, when I run the code for the first time, the file that is saved is empty, there is no figure. When I run it again, the figure made during the first run is saved…
Emil
  • 41
  • 2
0
votes
1 answer

Cropping the top and bottom output of ggsave from grid.arrange of PNG Files

library(grid) library(gridExtra) library(png) library(ggplot2) library(RCurl) PNG_1 <- readPNG(getURLContent("https://i.ibb.co/MVx1QsQ/A.png")) PNG_2 <- readPNG(getURLContent("https://i.ibb.co/kHVGNfQ/B.png")) PNG_3 <-…
0
votes
1 answer

Save a legend to a Boxplot with ggsave

I'm pretty new to R and have a question regarding ggsave. I use the following code to first create a box plot, then add a bee swarm plot on top of it and save it with ggsave. Now, I would like to add a p-value on the bottom of the plot. However, I…
RTobey
  • 1
0
votes
0 answers

ggsave alters figure when exporting to pdf

I've created a complex multi-facet figure using ggplot. When I save it using the basic ggsave command: ggsave("myplot.pdf", plot = my.plot) The margins of the figure facets and of the labels get changed. What it looks like in the Rstudio plot…
Nereus
  • 47
  • 5
0
votes
1 answer

Error while trying to save list of plots using marrangeGrob and ggsave

I'm getting error when trying to save list of lists of plots in one pdf this way: ggplot2::ggsave("plots.pdf", gridExtra::marrangeGrob(grobs = unlist(plots,recursive = F), nrow=2, ncol=1), device = "pdf",units = "in",width =…
0
votes
0 answers

Save a ggplot allowing panning and zooming

I'm creating a series of small line graphs relevant to different regions which I then save as grobs and plot onto a map of Europe. I can save this as a png file and can then zoom in to parts on the saved image just with standard windows photo zoom.…
0
votes
0 answers

ggsave cannot export a readable plot even with a dpi of 3000

Using the code below, I am trying to save a ggplot to as a png file. Although dpi is pretty high, the saved png file is not even readable. As shown in the image below, the export option in the files pane provides a better resolution. Is there any…
Nader Mehri
  • 514
  • 1
  • 5
  • 21
0
votes
1 answer

How to save a customize plot using ggsave with all customized properties?

I have a plot and then I changed some by default properties of ggplot like font face, font color, bold etc. However, when I am opening the plot using command or from Rstudio's plot the image contains all my customize property. However, when I am…
0Knowledge
  • 747
  • 3
  • 14