Last active
August 29, 2015 13:56
-
-
Save chriddyp/9038957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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