[R] GGSAVE does not save a good version of my graph

@vi@e@gross m@iii@g oii gm@ii@com @vi@e@gross m@iii@g oii gm@ii@com
Fri Jul 24 01:21:14 CEST 2026


I would guess you might want to read the manual page for ggsave() and see if the default for what it does for your output format can be tweaked for your needs. 

Here is one such manpage:

https://ggplot2.tidyverse.org/reference/ggsave.html



-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Bert Gunter
Sent: Thursday, July 23, 2026 6:55 PM
To: Sorkin, John <jsorkin using som.umaryland.edu>
Cc: r-help <r-help using r-project.org>
Subject: Re: [R] GGSAVE does not save a good version of my graph

Due to server security policies, all attachments were excised.

-- Bert

On Thu, Jul 23, 2026 at 3:45 PM Sorkin, John <jsorkin using som.umaryland.edu>
wrote:

> I am running R in RStudio. I am creating a graph, which I see in the plot
> window, and I use ggsave() to save a copy of the graph in a file.
>
> When I use look at the graph is RStudio's Plots window, the graph looks
> fine. When I click on the Plot window's export button, copy the plot to the
> clipboard and paste the graph into MS word, the graph looks fine. Please
> see first figure on attached MS word document.
>
> When I copy and paste the .tiff file saved by ggsave, the graph looks bad.
> Second figure on the attached MS word document. I think the graphs is being
> exported improperly by ggsave. I would appreciate any suggestions for
> improving the quality of the graph produced by ggsave.
>
> Please see code below and attached MS word document
>
>
>
>
> # Code to produce graph
>  ## Plot
>   zz <- ggplot(
>     df.long,
>     aes(
>       x = Date,
>       y = NumPeopleExposed,
>       color = factor(criticalvalue),
>       linetype = factor(criticalvalue),
>       group = factor(criticalvalue)
>     )
>   ) +
>     geom_point(size = 3) +
>     geom_line(linewidth = 1.5) +
>
>     scale_linetype_manual(
>       values = c(
>         "solid",
>         "dashed",
>         "dotted",
>         "dotdash",
>         "longdash",
>         "twodash"
>       )
>     ) +
>
>     labs(
>       title = species,
>       x = "Date",
>       y = "Number of People Exposed to Toxic Concentration",
>       color = "Critical Value",
>       linetype = "Critical Value"
>     ) +
>
>     ## Show every date on x-axis
>     scale_x_date(
>       breaks = sort(unique(df.long$Date)),
>       date_labels = "%Y-%m-%d"
>     ) +
>
>     theme_bw() +
>
>     theme(
>       axis.text.x = element_text(
>         angle = 45,
>         hjust = 1,
>         vjust = 1
>       )
>     )
>     print(zz)
>
> Code to save the graph
>  current_time <- Sys.time()
>   current_time
>   # Convert colons to dashes, remove spaces
>   formatted_time <- gsub(":", "-", format(current_time,
> "%Y-%m-%d_%H-%M-%S"))
>   formatted_time
>
>   #species="JDS"
>   # Save graph
>   mypath <- file.path("C:","Users","JSorkin","OneDrive - University of
> Maryland School of Medicine","HalemMilton","PaperAndAbstract")
>   mypath
>
>   myfilename <- paste0(species2,formatted_time,".tiff")
>   myfilename
>
>   ggsave(plot=zz,
>          path=mypath,
>          filename=myfilename,
>          device="tiff",
>          width=4,height=3,
>          units="in",
>          dpi=600)
>
>   cat("Ending (12) Plot Fraction Exposed\n")
>   }
>
>
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine, University of Maryland School of Medicine;
> Associate Director for Biostatistics and Informatics, Baltimore VA Medical
> Center Geriatrics Research, Education, and Clinical Center;
> Former PI Biostatistics and Informatics Core, University of Maryland
> School of Medicine Claude D. Pepper Older Americans Independence Center;
> Senior Statistician University of Maryland Center for Vascular Research;
>
> Division of Gerontology, Geriatrics and Palliative Medicine,
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> Cell phone 443-418-5382
>
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list