Skip to content

Commit

Permalink
Merge pull request plotly#1169 from plotly/inset-plot-fix-r
Browse files Browse the repository at this point in the history
update inset R example to be proper inset graph
  • Loading branch information
michaelbabyn authored Nov 9, 2018
2 parents 9f72cad + accb44d commit 370d865
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions _posts/r/subplots/2015-07-30-insets.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Insets in R | Plotly
name: Inset Plots
permalink: r/insets/
description: How to make a subplot in R with Plotly
description: How to make an inset plot in R with Plotly
layout: base
thumbnail: thumbnail/insets.jpg
language: r
Expand Down Expand Up @@ -42,12 +42,12 @@ See also the [chapter on subplots in the plotly book](https://cpsievert.github.i

```{r, results = 'hide'}
library(plotly)
p1 <- plot_ly(x = c(1, 2, 3), y = c(4, 3, 2))
p2 <- plot_ly(x = c(20, 30, 40), y = c(30, 40, 50)) %>%
layout(xaxis = list(domain = c(0.6, 0.95)),
yaxis = list(domain = c(0.6, 0.95)))
p <- subplot(p1, p2)
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'))
# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = api_create(p, filename="subplots-1")
Expand Down
18 changes: 9 additions & 9 deletions _posts/r/subplots/2015-07-30-insets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Insets in R | Plotly
name: Inset Plots
permalink: r/insets/
description: How to make a subplot in R with Plotly
description: How to make an inset plot in R with Plotly
layout: base
thumbnail: thumbnail/insets.jpg
language: r
Expand Down Expand Up @@ -34,7 +34,7 @@ packageVersion('plotly')
```

```
## [1] '4.5.2'
## [1] '4.8.0'
```

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

```r
library(plotly)
p1 <- plot_ly(x = c(1, 2, 3), y = c(4, 3, 2))
p2 <- plot_ly(x = c(20, 30, 40), y = c(30, 40, 50)) %>%
layout(xaxis = list(domain = c(0.6, 0.95)),
yaxis = list(domain = c(0.6, 0.95)))
p <- subplot(p1, p2)

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

<iframe src="https://plot.ly/~RPlotBot/3936.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>
<iframe src="https://plot.ly/~RPlotBot/5513.embed" width="800" height="600" id="igraph" scrolling="no" seamless="seamless" frameBorder="0"> </iframe>

0 comments on commit 370d865

Please sign in to comment.