Update to Lizzie Bennet Text Analysis Using Plotly

Daniela Vázquez recently published her blog post on Last Week Tonight. She used a bunch of code from my previous LBD analysis (THANKS FOR THE LOVE DANIELA! :heart:) and also created this super cool plotly widget.

I had never used ggplot and plotly before and wanted to give it a try, recreating a previous plot of sentiment by LBD episode.

library(viridis)
library(plotly)

p <- ggplot(lbsentiment, aes(x=index, sentiment, fill=as.factor(index), text=title)) +
    geom_bar(stat = "identity", show.legend = FALSE) +
    theme_minimal(base_size = 13) +
    geom_text(aes(x=index, y=plot_sentiment, label=plot_index), size=3.5) + 
    labs(title = "Sentiment in Lizzie Bennet Diaries",
         y = "Sentiment"
         ) +
    scale_fill_viridis(end = 0.75, discrete=TRUE, direction = -1) +
    scale_x_discrete(expand=c(0.02,0)) +
    theme(strip.text=element_text(hjust=0)) +
    theme(strip.text=element_text(face = "italic")) +
    theme(axis.title.x=element_blank()) +
    theme(axis.ticks.x=element_blank()) +
    theme(axis.text.x=element_blank()) +
    theme(legend.position = "none")

ggplotly(p, tooltip="text", width=750, height=400)
Written on May 31, 2017