Show Sidebar Hide Sidebar

Log Plots in R

How to make a plot with logarithmic axes 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.9.1'

Log Axes

d <- diamonds[sample(nrow(diamonds), 1000), ]
# without log scales
p <- plot_ly(d, x = ~carat, y = ~price) %>% add_markers()

# with log scales
p <- layout(p, xaxis = list(type = "log"),
       yaxis = list(type = "log"))