Show Sidebar Hide Sidebar

Setting Graph Size in R

How to change the size of graphs in R.

New to Plotly?

Plotly's R library is free and open source!
Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Version 4 of Plotly's R package is now available!
Check out this post for more information on breaking changes and new features available in this version.

## [1] '4.5.2'

Customize Margins and Plot Size

m <- list(
  l = 50,
  r = 50,
  b = 100,
  t = 100,
  pad = 4
p <- plot_ly(x = seq(0, 8), y = seq(0, 8)) %>%
  layout(autosize = F, width = 500, height = 500, margin = m)

# Create a shareable link to your chart
# Set up API credentials:
chart_link = api_create(p, filename="sizing-1")
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.