I have found that if I mix calls to ggplot and ggplotly together, only the last chart appears and overwrites the others or in some cases blocks the display of subsequent charts. I need to be able to produce some charts with ggplot and others with the interactive ggplotly.
Has anyone encountered this problem? Is there a way to perhaps reset the plot mechanism in RStudio without wiping out all of the plots (e.g., NOT dev.off())?
ggplot plot should go to plot pane, while ggplotly plot should go to view pane so they should not interfere with each other. You are using same variable for holding the ggplot object, so that will override each other obviously. Did you try different variable names or just use pipe to avoid temporary variable?
I'm not sure what you mean by "plot pane" and "view pane." The windows of RStudio are: Source, Console, Environment/History, and Files/Plots. Which one is the view pane?
Tried the code you suggested and the piping doesn't produce any plot at all. Here is the modified code as suggested:
{ggplot(data = new_df, aes(
x = Category, y = Value)) +
geom_bar(position = position_dodge(), stat = "identity")} %>% ggplotly
If I add a print() around this statement I get the line graph but still get the overwrite by the bar chart.
UPDATE: ggplotly is going to the Viewer pane and ggplot is going to the Plot pane as outlined by andresrcs!!