2
2
title : Insets in R | Plotly
3
3
name : Inset Plots
4
4
permalink : r/insets/
5
- description : How to make a subplot in R with Plotly
5
+ description : How to make an inset plot in R with Plotly
6
6
layout : base
7
7
thumbnail : thumbnail/insets.jpg
8
8
language : r
@@ -34,7 +34,7 @@ packageVersion('plotly')
34
34
```
35
35
36
36
```
37
- ## [1] '4.5.2 '
37
+ ## [1] '4.8.0 '
38
38
```
39
39
40
40
#### Basic Inset
@@ -44,16 +44,16 @@ See also the [chapter on subplots in the plotly book](https://cpsievert.github.i
44
44
45
45
``` r
46
46
library(plotly )
47
- p1 <- plot_ly(x = c( 1 , 2 , 3 ), y = c( 4 , 3 , 2 ) )
48
- p2 <- plot_ly( x = c(20 , 30 , 40 ), y = c(30 , 40 , 50 )) % > %
49
- layout( xaxis = list ( domain = c(0.6 , 0.95 )),
50
- yaxis = list (domain = c(0.6 , 0.95 )))
51
- p <- subplot( p1 , p2 )
52
-
47
+ p <- plotly :: plot_ly()
48
+ p <- plotly :: add_trace( p , x = c(1 , 2 , 3 ), y = c(4 , 3 , 2 ), mode = ' lines ' )
49
+ p <- plotly :: add_trace( p , x = c( 20 , 30 , 40 ), y = c(30 , 40 , 50 ), xaxis = ' x2 ' , yaxis = ' y2 ' , mode = ' lines ' )
50
+ p <- plotly :: layout( p , xaxis2 = list (domain = c(0.6 , 0.95 ), anchor = ' y2 ' ),
51
+ yaxis2 = list ( domain = c( 0.6 , 0.95 ), anchor = ' x2 ' ) )
52
+
53
53
# Create a shareable link to your chart
54
54
# Set up API credentials: https://plot.ly/r/getting-started
55
55
chart_link = api_create(p , filename = " subplots-1" )
56
56
chart_link
57
57
```
58
58
59
- <iframe src =" https://plot.ly/~RPlotBot/3936 .embed " width =" 800 " height =" 600 " id =" igraph " scrolling =" no " seamless =" seamless " frameBorder =" 0 " > </iframe >
59
+ <iframe src =" https://plot.ly/~RPlotBot/5513 .embed " width =" 800 " height =" 600 " id =" igraph " scrolling =" no " seamless =" seamless " frameBorder =" 0 " > </iframe >
0 commit comments