plotly_build ignores geom_text(vjust)

Created on 24 Oct 2016  路  6Comments  路  Source: ropensci/plotly

Hello,

The function plotly_build is very useful for introducing a ggplot in a plotly display. When it's bars, and with a label via geom_text, it doesn't follow the vertical alignment vjust function.

Using this function:

SampleData <- data.frame(Name = c("Peter", "Andrew"), Result = c(6, 9))
SamplePlot <- ggplot(SampleData, aes(Name, Result)) + geom_bar(stat = "identity") + 
        geom_text(aes(label=Result), color = "white", vjust = 4)

Using only ggplot, the texts are placed below the border:
ggplot_out

When I use the plotly_build function that vertical alignement is lost
plotly_build(SamplePlot)
The display is the same as if the vjusthadn't been introduced
plotly_build_out

enhancement ggplotly

All 6 comments

Same here. Whenever I use geom_text and wrap it with ggplotly(), plotly ignores hjust, vjust but also size.

any update on this issue yet? thx.

Data labels are important, hope this issue is on the roadmap.

Another vote to have this issue addressed.

This likely won't be fixed anytime soon, but you could leverage the plotly.js api for doing this sort of thing:

d <- data.frame(Name = c("Peter", "Andrew"), Result = c(6, 9))
p <- ggplot(SampleData, aes(Name, Result)) + geom_bar(stat = "identity")
ggplotly(p) %>% style(text = d$Result, textposition = "auto")

I hate to ask again, but does anyone has an update on this?

Was this page helpful?
0 / 5 - 0 ratings