plotly / plotly/plotly.R

ggplotly + subplot(shareX=TRUE) causes date axis tick labels to disappear after zoom/pan

Open
#2,489 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When combining two ggplotly() objects using subplot(..., shareX = TRUE), x-axis tick labels disappear after zooming/panning.

This happens specifically with date-time x axes.

The hover labels still show correct datetime values, but axis ticks disappear.

Reproducible example

library(tidyverse)
library(lubridate)
library(plotly)
library(viridisLite)

d = tibble(
  time = seq(
    ymd_hms("2019-01-01 00:00:00"),
    by = "10 sec",
    length = 1e5
  ),
  y = cumsum(rnorm(1e5))
)

d2 = expand.grid(
  date = unique(date(d$time)),
  y = 48 / 2^8 * 2^(seq(
    0,
    log2(48 / (48 / 2^8)),
    by = 1/20
  ))
) %>%
  as_tibble() %>%
  mutate(z = rnorm(n()))

g1 = ggplot(d, aes(time, y)) +
  geom_line(linewidth = 0.3) +
  theme_bw()

g2 = ggplot(
  d2 %>%
    mutate(date = as.POSIXct(date) + 12*3600),
  aes(date, log2(y), fill = z)
) +
  geom_raster() +
  scale_fill_gradientn(colours = turbo(100)) +
  theme_bw()

p1 = ggplotly(g1)
p2 = ggplotly(g2)

subplot(
  p1,
  p2,
  nrows = 2,
  shareX = TRUE
) %>%
  layout(
    dragmode = "pan"
  )

Expected behavior

x-axis tick labels should remain visible and automatically update during zoom/pan.

Actual behavior

x-axis tick labels disappear after zooming/panning.

Session info

sessionInfo()

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 with the reproducible R example using ggplotly(), subplot(), shareX = TRUE, and the pan/zoom interaction. Compare the date-time axis behavior before and after zooming or panning; done means x-axis tick labels remain visible and update automatically.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.