Show Sidebar Hide Sidebar

LaTeX Typesetting in R Graphs in R

How to add LaTeX to R graphs.

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.

library(plotly)
packageVersion('plotly')
## [1] '4.5.2'

LaTeX Typesetting

Currently broken https://github.com/ropensci/plotly/issues/375

library(plotly)
p <- plot_ly(x = c(1, 2, 3, 4), y = c(1, 4, 9, 16),
        name = "$\\alpha_{1c} = 352 \\pm 11 \\text{ km s}^{-1}$") %>%
  add_trace(x = c(1, 2, 3, 4), y = c(0.5, 2, 4.5, 8),
            name = "$\\beta_{1c} = 25 \\pm 11 \\text{ km s}^{-1}$") %>%
  layout(xaxis = list(title = "$\\sqrt{(n_\\text{c}(t|{T_\\text{early}}))}$"),
         yaxis = list(title = "$d, r \\text{ (solar radius)}$"))

# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = plotly_POST(p, filename="latex/1")
chart_link
Still need help?
Contact Us

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