Skip to content

geom_label() in plotly #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lindsayrutter opened this issue Apr 12, 2016 · 2 comments
Closed

geom_label() in plotly #546

lindsayrutter opened this issue Apr 12, 2016 · 2 comments

Comments

@lindsayrutter
Copy link

Thank you for such a useful and user-friendly package!

I recently tried to use plotly for a ggplot2 object that had geom_label(). I received a warning message that geom_label() has yet to be implemented in plotly, and to post an example code here for any geom that may be useful to be implemented.

library(ggplot2)
library(plotly)

dat=data.frame(label=paste0("label",seq(1:5)), xstart = seq(10,50, by=10), ystart = seq(1:5)+.1, xend = c(seq(20,50, by=10), 50), yend = c(seq(1:4)+.9, 5.1), x = seq(10,50, by=10), y=seq(1:5))

myPlot = ggplot2::ggplot(data = dat,ggplot2::aes(x = x, y = y, label=label)) +
  ggplot2::geom_segment(ggplot2::aes(x=xstart, y=ystart, xend=xend, yend=yend)) +
  ggplot2::geom_label(fill = "grey80", size = 3) +
  ggplot2::scale_x_continuous(expand = c(.1, .1))

ggplotly(myPlot, tooltip = c("x", "label"))

The static myPlot object itself has five labels, labeled as "label1", "label2", "label3", "label4", and "label5" with x values of 10, 20, 30, 40, and 50. I was aiming for the last line to allow the interactive tooltip to show the label and x values for each of the five labels. Instead, it seems, upon running the last line, that the geom_labels disappear, and upon hovering over, the interactivity is on the values at the corners of the edges from the geom_segment().

I just wanted to post it here in case it is of something of interest to the developers or others. Thank you!

@cpsievert
Copy link
Collaborator

Duplicate of #348

@dbo99
Copy link

dbo99 commented Dec 17, 2018

adding support for geom_label (the duplicate page is locked)

I find geom_label very convenient in ggplot and would find it just as useful if it were available in ggplotly, as it makes geom_hline and geom_vlines easily labelable/readable, with nice text balloons and masking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants