Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 370d865

Browse files
authored
Merge pull request plotly#1169 from plotly/inset-plot-fix-r
update inset R example to be proper inset graph
2 parents 9f72cad + accb44d commit 370d865

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

_posts/r/subplots/2015-07-30-insets.Rmd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Insets in R | Plotly
33
name: Inset Plots
44
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
66
layout: base
77
thumbnail: thumbnail/insets.jpg
88
language: r
@@ -42,12 +42,12 @@ See also the [chapter on subplots in the plotly book](https://cpsievert.github.i
4242

4343
```{r, results = 'hide'}
4444
library(plotly)
45-
p1 <- plot_ly(x = c(1, 2, 3), y = c(4, 3, 2))
46-
p2 <- plot_ly(x = c(20, 30, 40), y = c(30, 40, 50)) %>%
47-
layout(xaxis = list(domain = c(0.6, 0.95)),
48-
yaxis = list(domain = c(0.6, 0.95)))
49-
p <- subplot(p1, p2)
50-
45+
p <- plotly::plot_ly()
46+
p <- plotly::add_trace(p, x = c(1, 2, 3), y = c(4, 3, 2), mode='lines')
47+
p <- plotly::add_trace(p, x = c(20, 30, 40), y = c(30, 40, 50), xaxis='x2', yaxis='y2', mode='lines')
48+
p <- plotly::layout(p, xaxis2 = list(domain = c(0.6, 0.95), anchor='y2'),
49+
yaxis2 = list(domain = c(0.6, 0.95), anchor='x2'))
50+
5151
# Create a shareable link to your chart
5252
# Set up API credentials: https://plot.ly/r/getting-started
5353
chart_link = api_create(p, filename="subplots-1")

_posts/r/subplots/2015-07-30-insets.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Insets in R | Plotly
33
name: Inset Plots
44
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
66
layout: base
77
thumbnail: thumbnail/insets.jpg
88
language: r
@@ -34,7 +34,7 @@ packageVersion('plotly')
3434
```
3535

3636
```
37-
## [1] '4.5.2'
37+
## [1] '4.8.0'
3838
```
3939

4040
#### Basic Inset
@@ -44,16 +44,16 @@ See also the [chapter on subplots in the plotly book](https://cpsievert.github.i
4444

4545
```r
4646
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+
5353
# Create a shareable link to your chart
5454
# Set up API credentials: https://plot.ly/r/getting-started
5555
chart_link = api_create(p, filename="subplots-1")
5656
chart_link
5757
```
5858

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

Comments
 (0)