forked from ecoaspect/knitr-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanadian-cities.Rmd
34 lines (27 loc) · 883 Bytes
/
canadian-cities.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
See the source code and more examples here: https://github.com/plotly/knitr-demos
```{r}
library(plotly)
p = plotly('R-demos', 'p9g4f35ytd')
```
```{r}
#Load maps
library(maps)
data(canada.cities)
#Create the hexagone map
trace1 <- list(x=map(regions="canada", plot=FALSE)$x,
y=map(regions="canada", plot=FALSE)$y)
#Create the plotable city data
trace2 <- list(x= canada.cities$long,
y=canada.cities$lat,
text=canada.cities$name,
type="scatter",
mode="markers",
marker=list("size"=sqrt(canada.cities$pop/max(canada.cities$pop))*100,
"opacity"=0.5))
```
```{r, plotly=TRUE, width=600, height=600}
p$iplot(trace1, trace2, kwargs=list(filename='canadian cities'))
```
```{r, plotly=TRUE, width=600, height=600}
p$embed('https://plot.ly/~ChrisP/9/600/600')
```