plotly / plotly/plotly.R

plotly_build ignores geom_text(vjust)

Open
#769 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement ggplotly
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:
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.