plotly / plotly/plotly.R

ggplotly: problems with facet_grid/axes

Open
#1,086 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ggplotly
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

I'm trying to display some block-matrix-like plot, and there are a few regressions when converting from ggplot to ggplotly conversion (ranked by severity):

  • degenerated (1 value) discrete axes are implicitly converted into continuous numeric axis centered around 1, original labels not displayed
  • switch="both" and strip.placement = "outside" options ignored (here it's important because with ggplot I am able to have sort-of 2-level hierarchy for X and Y axes, which ggplotly breaks)
  • some subplots with missing data are displayed (at 3x3 position), some don't (2x2 position)
  • the margins for the X labels are too small (is the text rotation considered when calculating the necessary space?)
  • space="free" option ignored
  • within my shiny application the diagonal subplots miss the fill color. It's an important issue, but I cannot make a small reproducible example (screenshot attached).

ggplot2
capza1_ggplot_render

ggplotly
capza1_plotly_render

ggplotly from Shiny app
capza1_plotly_shiny_render

The code

require(readr)
require(plotly)
require(ggplot2)

peakXpepmod.df <-  read_tsv("CAPZA1_example.txt",
                            col_types = list("pepmod_id"="c", "peak_id"="c", "proteoform_id"="c", "pmgroup_id"="c")) %>%
  dplyr::mutate(pepmod_id = factor(pepmod_id),
                peak_id = factor(peak_id),
                proteoform_id = factor(proteoform_id),
                pmgroup_id = factor(pmgroup_id))

p <- ggplot(peakXpepmod.df) +
  geom_point(aes(x = pepmod_id, y = peak_id,
                 color = proteoform_id), shape=15, size=8) +
  geom_point(aes(x = pepmod_id, y = peak_id,
                 shape = pmgroup_id), size=5) +
  scale_x_discrete("Pepmods") + scale_y_discrete("Peaks") +
  theme( axis.line = element_line(colour = "gray80"),
         axis.ticks = element_line(colour = "gray80"),
         axis.text.x = element_text(angle = 90, hjust = 1),
        strip.background = element_rect(colour="gray"),
        strip.placement = "outside") +
  facet_grid(proteoform_id ~ pmgroup_id, switch="both", scales = "free", space = "free")

# ggplot
p

# ggplotly
ggplotly(p)

The dataset
CAPZA1_example.txt

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

Reproduce the report by running the supplied R example with CAPZA1_example.txt, comparing p with ggplotly(p), and focusing on facet_grid conversion. No project file or test is named; done means addressing the listed axis, strip, missing-subplot, margin, spacing, and fill-color regressions, with particular attention to the cases that can be reproduced.

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
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.