plotly_build ignores geom_text(vjust)
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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:

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

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided SampleData and SamplePlot example and running plotly_build(SamplePlot). Trace the ggplot geom_text conversion, focusing on how vjust is handled for bar labels. Done means the built Plotly display preserves the vertical alignment shown by ggplot.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100