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!
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.7.0.9000'


#### 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)}$"))