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
1
vote
2 answers

Save ggplot with twice with different file formats with ggsave (ggplot2)

Is there a way to save a ggplot twice to different file formats with just one ggsave command? E.g. plot.pdf and plot.png
justinian482
  • 845
  • 2
  • 10
  • 18
0
votes
0 answers

ggsave is not saving my scatterplot correctly

I am trying to save a scatterplot that looks nice in RStudio but is not working when I am saving it in a loop with ggsave() or png(). I tried changing the width and the height but it is not working saved from the plot in Rstudio saved with ggsave or…
0
votes
1 answer

Exporting plot panel as the same size no matter how wide the legend is

I’m having trouble exporting plots in ggplot. I want to display my data using different variables in different plots and have the plot panel size export to the same size every time. My issue is that sometimes my legends are wider or shorter and R…
axc
  • 3
  • 2
0
votes
0 answers

ggplot add gradient in ggsave

I'm trying to save a plot from ggplot2. I'm trying two methods: tiff('path/plot.tiff', units="in", width=8, height=5, res=300) dev.off() and ggsave('test.tiff', device = 'tiff', units = 'in', width=8, height=5) But ggsave add "gradient" in the…
0
votes
0 answers

How can I use html output instead of png from my R script on Knowage R webservice?

Using Knowage, its stated that the output can either be an or html. I have tried unsuccessfully to use the html output but it keeps coming back as R error on the application, I have used different methods where it creates the html file in the…
IfeOluwa
  • 17
  • 4
0
votes
1 answer

ggplot spatial data and ggsave unique id's in a for loop

I have a dataset with watersheds across 3 provinces. Each watershed has a corresponding shapefile, and score from 0 to 1 for ecosystem disruption under 3 rcp (climate projection models). Here is the head of my dataframe: ws rcp ecodisrup…
Megan S
  • 3
  • 2
0
votes
1 answer

Save multiple plots as pdf files using lapply and ggplot fail in R

I have a data frame with a grouping variable and I want to create and save a plot for each group using ggplot. I tried to use lapply and split the data by group, then use pdf to save the plot as a file named after the group. However, when I run the…
zhang
  • 185
  • 7
0
votes
2 answers

Save ggplot from Shiny to a folder of my choosing and with a name of my choosing

I have an R Shiny document where a user defines their chosen data and parameters, colours, etc. for a ggplot plot that is displayed in a "PlotOutput" area. I want to add a button that will save the image that is currently in a plotting area as a PNG…
Leonhard Euler
  • 231
  • 1
  • 7
0
votes
1 answer

Problem saving ggplot plot in high resolution (colors change after saving)

I tried several ways of saving my plots from R, but non of them work. Either they are blurry or the colors of the barplot change and the bars become somewhat transparent with an uneven color. The plots were created with ggplot2. This is what I've…
Sophya
  • 11
  • 2
0
votes
0 answers

Exporting ggplot with extrafont using ggsave

To have my plot match the font used for my writing, I added the font via the extrafont package. Thus, I performed the following procedure: library(extrafont) font_import() loadfonts(device = "win") This allowed me to change the font of my plot via…
Nick Glättli
  • 421
  • 1
  • 7
0
votes
0 answers

How to save a graph with ggsave in a Windows folder structure?

I have following folder structure. C:\Folders\Subfolder\Sub-Subfolder\Sub-Sub-Subfloder and also have file called grphics01.pdf and I want to save grphics01.pdf file to this C:\Folders\Subfolder\Sub-Subfolder\Sub-Sub-Subfloder folder. My current…
book1001
  • 3
  • 2
0
votes
1 answer

ggsave ggsurvplot with risk.table

I am trying to save a ggsurvplot with risk.table using ggsave. However, the output off ggsave is always just the risk.table. I also tried this and this. None is working. library(data.table) library(survival) library(survminer) OS <- c(c(1:100),…
gernophil
  • 177
  • 2
  • 6
0
votes
0 answers

RMarkdown | ggsave is producing different results in different devices

I created an RMarkdown file to create 4 charts and save them on my desktop. I'm using ggsave and have forced the DPI to 280 so that the output images look good. The issue I'm having is that when the script is run on my colleague's computer, the…
Jahannie
  • 1
  • 1
0
votes
0 answers

Text corrupts when saving ggplot object to pdf

I create a plot from data in R using ggplot2. When saving the ggplot object to a png file, the plot looks exactly as it should (see picture). When saving the same ggplot object to a pdf, all text corrupts. Anyone knows a solution? Results of…
0
votes
0 answers

saving ggplot figure with limiting megapixels using ggsave

I am trying to save my figure with 900 dpi but at the same time I dont want it to exceed 40 megapixels. ggsave(p, filename = 'fig.tiff',dpi = 900,compression = "lzw") thanks i tried limitsize option but it is in inches not in pixels
MMJJ
  • 21
  • 2