Skip to content

Instantly share code, notes, and snippets.

@chriddyp
Last active August 29, 2015 13:56
Show Gist options
  • Save chriddyp/9038957 to your computer and use it in GitHub Desktop.
Save chriddyp/9038957 to your computer and use it in GitHub Desktop.
See the source code here: https://gist.github.com/chriddyp/9038957
```{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')
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment