In my previous post I showed a fully interactive online graph of one of the plots in my recent paper on leadership in sticklebacks. In this follow-up post I will explain how to easily create such an interactive plot yourself. To be able to do this you will need some experience with the R-language and ideally with ggplot2.
First create an account at plot.ly, which is free. After you have created your account, go to “settings” and click on “generate API key”. You will need your username and this key to link your account to R.
Now you have your account ready start-up R and set-up the R workspace:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Install the necessary packages install.packages("ggplot2") install.packages("gdata") install.packages("devtools") install_github("ropensci/plotly") # Now load the packages library(ggplot2) library(gdata) library("devtools") library(plotly) # Set your Plotly user credentials set_credentials_file("your-username", "your-credentials") |