Part12 Interactive plots with {plotly}
{plotly} is a package that makes interactive graphs.
There are many applications to plotly, but a simple one is to convert a plot created by ggplot into an interactive version.
First we can install plotly (bottom-right panel -> Packages -> Install).
And then we load the package: tick the package in the list.
Let’s read again one of our first data file:
We can first save the “ggplot” as an object myplot:
myplot <- ggplot(data=geneexp, mapping=aes(x=sample1, y=sample2, label=Gene, color=DE)) +
geom_point()
And then input that object into the ggplotly() function.
The interactive plot should appear in the Viewer tab (bottom-right panel). Not that you can zoom into the plot!
Customize what appears in the tooltip box. For example, here, we only show the gene label information:
It also works for different types of plots: for example, barplots.
You can add ggplot2 layers / components: