Documentation

Embedding GGPlot2 Graph to Web using Plot.Ly

  1. Include the ‘library(plotly)’ to the R script
  2. Assign your GGPlot object to a variable
    Example:
    p <- ggplot(testdf, aes(SentenceNumber, value, col=variable))+
    geom_point(aes(pch=variable))+
    geom_line() +
    annotate(“rect”, xmin=1, xmax=30, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightgreen”)+
    annotate(“rect”, xmin=30, xmax=38, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightblue”)+
    annotate(“rect”, xmin=38, xmax=43, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightpink”)+
    annotate(“rect”, xmin=43, xmax=46, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightgreen”)+
    annotate(“rect”, xmin=46, xmax=48, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightyellow”)+
    annotate(“rect”, xmin=48, xmax=50, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightblue”)+
    annotate(“rect”, xmin=50, xmax=55, ymin=-Inf, ymax=Inf, alpha=.4, fill=”lightyellow”)+
    labs(title=”Negative newdata <- mydata[c(1,5:10)]emotions through the Sentimental Narrative”, x=”sentence number”, y=”Intensity of Emotion”, color=”Associated Emotions”, pch=”Associated Emotions”)+
    scale_color_brewer(palette = “Set1”)+geom_smooth(aes( group = 1 ))