Menu

Guide8 min read

How to Use ggsave for High-Resolution Figures (PNG, PDF, SVG, TIFF)

By Francesco Villasmunta
How to Use ggsave for High-Resolution Figures (PNG, PDF, SVG, TIFF)

Exporting blurry figures with overlapping labels is a common cause of journal peer-review delay. In R, ggsave() provides a convenient utility to export publication-ready plots.

In This Guide

0.Live Code: Plot and Export

1.The ggsave Formula

2.Exporting PNG vs Vector (PDF/SVG)

3.Sizing for Journal Columns

4.TIFF Export for Medical Journals

0. Live Code: Plot and Export

Sizing and resolution testing. Customize parameters using Python below, or upload your data to run R directly.

1. The ggsave Formula

By default, `ggsave()` saves the last displayed plot. We recommend explicitly binding the plot object to prevent saving errors:

R / ggplot2

p1 <- ggplot(df, aes(x, y)) + geom_point()

# Explicit export formula
ggsave(
  filename = "figure1.png",
  plot = p1,
  device = "png",
  width = 6,
  height = 4.5,
  units = "in",
  dpi = 300
)

2. Exporting PNG vs Vector (PDF/SVG)

Try it

Try it now: turn this method into your next figure

Apply the same approach to your own dataset and generate clean, publication-ready code and plots in minutes.

Open in Plotivy Analyze

Newsletter

Get a weekly Python plotting tip

One concise tip each week for cleaner, faster scientific figures. Built for researchers who publish.

No spam. Unsubscribe anytime.

Use vector formats (`.pdf`, `.svg`) for publication figures because they scale infinitely without raster pixelation. Use raster formats (`.png`, `.tiff`) for web or embedded presentations:

R / ggplot2

# Vector export (no DPI required)
ggsave("figure1.pdf", plot = p1, width = 150, height = 110, units = "mm")
ggsave("figure1.svg", plot = p1, width = 150, height = 110, units = "mm")

3. Sizing for Journal Columns

Most journals use a two-column layout. Size your figures matching their column configurations to avoid scaling text distortions:

R / ggplot2

# Single-column target: ~80 to 90 mm
ggsave("fig_single.pdf", plot = p1, width = 85, height = 65, units = "mm")

# Double-column target: ~170 to 180 mm
ggsave("fig_double.pdf", plot = p1, width = 175, height = 130, units = "mm")

4. TIFF Export for Medical Journals

Medical journals often demand LZW-compressed TIFF formats. Specify this using `compression = "lzw"`:

R / ggplot2

ggsave("figure1.tiff", plot = p1, width = 120, height = 90, units = "mm",
       dpi = 600, compression = "lzw")

Chart gallery

Explore related formats

Review chart standards.

Browse all chart types →
Scatter plot of height vs weight colored by gender with regression line
Statisticalmatplotlib, seaborn
From the chart galleryCorrelation analysis between metrics

Scatterplot

Displays values for two variables as points on a Cartesian coordinate system.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
import pandas as pd

# Generate sample data
np.random.seed(42)
n_samples = 200
height = np.random.normal(170, 8, n_samples)
weight = height * 0.6 + np.random.normal(0, 8, n_samples) - 50
Multi-line graph showing temperature trends for 3 cities over a year
Time Seriesmatplotlib, seaborn
From the chart galleryStock price tracking over time

Line Graph

Displays data points connected by straight line segments to show trends over time.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

# Generate temperature data for 3 major US cities over 12 months
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
nyc = [30, 32, 40, 52, 65, 75, 82, 81, 74, 63, 50, 38]
miami = [65, 66, 70, 76, 82, 87, 90, 90, 87, 80, 72, 66]
chicago = [25, 27, 35, 48, 62, 72, 80, 79, 71, 60, 45, 32]

# Create figure with enhanced styling

Export ggplot2 Figures Online

Upload your data and describe the design. Plotivy writes the ggplot2 code and executes it instantly.

Use R Analyzer
Tags:#R#ggplot2#ggsave#export figures#high resolution

Found this helpful? Share it with your network.

FV
Francesco Villasmunta

Experimental Physicist & Photonics Researcher

Hands-on experience in silicon photonics, semiconductor fabrication (DRIE/ICP-RIE), optical simulation, and data-driven analysis. Built Plotivy to help researchers focus on discoveries instead of data struggles.

More about the author

Visualize your own data

Apply the techniques from this article to your own datasets. Upload CSV, Excel, or paste data directly.

Start Analyzing - Free