Black Lives Matter. Please consider donating to Black Girls Code today.

Plotly R inset chart

I am looking for ways to inset a chart in poorly using R similar to this example in Python. R Plotly’s inset example appears to work differently than Python’s Plotly. Is there a way to recreate the inset example from the Python example?

Hey plotly. Can you help me with this?

@adambcamroon, yes you can make a similar graph using R (I made a PR to update the R example).

p <- plotly::plot_ly()
p <- plotly::add_trace(p, x = c(1, 2, 3), y = c(4, 3, 2), mode='lines')
p <- plotly::add_trace(p, x = c(20, 30, 40), y = c(30, 40, 50), xaxis='x2', yaxis='y2', mode='lines')
p <- plotly::layout(p, xaxis2 = list(domain = c(0.6, 0.95), anchor='y2'),
         yaxis2 = list(domain = c(0.6, 0.95), anchor='x2'))