Questions tagged [ggplotly]

ggplotly is a function which converts a ggplot object into an interactive plotly object. It enables the usage of functions like zoom, hover, playing with the axis, appearing/disappearing group of points.

For more information and examples, please visit the website.

799 questions
3
votes
2 answers

Render ggplotly() in R Markdown github_document

Interactive graphs created with ggplotly() go along nicely with html_document output in R Markdown, see eg. RMarkdown and ggplotly. For github_document output, however, the knitted HTML preview file does not show ggplotly() graphs. I adopted the…
fdetsch
  • 5,239
  • 3
  • 30
  • 58
3
votes
4 answers

Is there a way to add the bin range label into the tooltip for a histogram using ggplotly in R?

library(tidyverse) library(ggplot2) library(plotly) data(mpg) ggplotly( mpg %>% ggplot(aes(x=hwy)) + geom_histogram(), tooltip = ("all")) When you hover over the bar, I'd like for the tooltip to show the start and stop of the bin (e.g.…
Tyler Knight
  • 183
  • 1
  • 9
3
votes
0 answers

geom_area renders differently between ggplot and ggplotly

I'm a little confused as to why ggplot can render geom_area correctly in the first plot, but when wrapped with ggplotly it produces something a little different. Any insights? library(tidyverse) library(plotly) my_dates <- Sys.Date() +…
Ryan
  • 281
  • 3
  • 12
3
votes
1 answer

Plotly (ggplotly R) Scroll zoom, label size and tooltip options

I was wondering how can I enable zooming into the plot by scrolling rather than using the zoom button to select a specific area since I need a dynamic exploration of the data at different resolutions. Ideally, I would have something like google maps…
AMM
  • 2,195
  • 2
  • 20
  • 28
3
votes
0 answers

ggplotly and geom_text vjust/hjust - how to achieve this static plot?

I've created the following plot which I'm quite pleased with when it's static - however, I wanted to make it interactive so when people hover over you can see the seasons (like pudding.cool has done here. The static plot I have: The code to achieve…
Dunc P
  • 33
  • 4
3
votes
1 answer

Replicate ggplot2 chart with facets and arrow annotations in plotly

I want to replicate a ggplot2 chart in plotly, to that end I have tried to use the ggplotly function. The chart is the following (p_arrow): library(data.table) library(ggplot2) library(plotly) dset <- data.table(x = c(0, 1), y =…
Jon Nagra
  • 1,538
  • 1
  • 16
  • 36
3
votes
1 answer

Controlling order of points in ggplotly in R

Consider the problem (and the reproducable example) given in controlling order of points in ggplot2 in R?. The solution provided there (first order the data.frame, then plot) is working also for me. However, when I want to view the resulting plot…
yasel
  • 433
  • 3
  • 13
3
votes
1 answer

Cumulative points over year on map with R ggplot2 and ggplotly

I am trying to plot new locations opened over each month on a map cumulatively. I am able to create an animation with new locations each month, but not cumulatively. In other words, I want to see the new locations add to the existing ones. Here is…
Wendy
  • 144
  • 9
3
votes
1 answer

Control legend in ggplotly when using subplot

I use the R plotly package and the functions ggplotly and subplot to create an interactive plot consisting of multiple individually interactive ggplot2 plots. Some of the plots share the same grouping variables. col <- factor(rep(c(1, 2), 5)) fill…
elmo
  • 325
  • 1
  • 12
3
votes
1 answer

Using frame parameter to making a plot from ggplot to plotly

Here is my data: data <- data.table(year = rep(1980:1985,each = 5), Relationship = rep(c(" Acquaintance","Unknown","Wife","Stranger","Girlfriend","Friend"), 5), N = sample(1:100, 30) ) I can…
Tao Hu
  • 287
  • 2
  • 12
3
votes
1 answer

Add secondary x and y axis on ggplotly scatter plot

I have this data: structure(list(ID = structure(c(3L, 4L, 4L, 4L, 4L, 4L, 1L, 5L, 2L, 2L), .Label = c("015753e0-8574-4b13-88d7-627292d52272", "2721a25c-cc0e-43d3-abd2-b29a0da8b9d0", "60a7614a-63bb-4bb9-91ac-520549853c19",…
3
votes
1 answer

Generating interactive partial dependence plots in R using loop extremely slow

I'm trying to generate interactive partial dependence plots by looping over the columns in the data set. A reproducible example: library(pdp) library(xgboost) library(Matrix) library(ggplot2) library(plotly) data(mtcars) target <-…
Debbie
  • 391
  • 2
  • 18
3
votes
2 answers

ggplotly fails with geom_vline() with xintercept Date value

Trying to use ggplotly to graph time series data with a vertical line to indicate dates of interest. Call fails with Error in Ops.Date(z[[xy]], 86400000) : * not defined for "Date" objects. I have tried unsuccessfully using both the latest CRAN and…
3
votes
1 answer

ggplotly with geom_ribbon grouping

I'm having some problems in converting a ggplot in to a plotly object, and retaining the same legend attributes. What I want: For grouped series, a single line for fit, and faded region for ribbon of same colour, with transparency No lines at the…
Jonny Phelps
  • 2,687
  • 1
  • 11
  • 20
3
votes
1 answer

Change the color of point on click and keep it unchanged using R Shiny

I am trying to work on creating the graph using plotly. When the user clicks on any geom_point in the plot using R shiny, it should change the color and keep it unchanged. Currently, my code is working fine. When the user clicks on any geom_point in…