ggplotly + subplot(shareX=TRUE) causes date axis tick labels to disappear after zoom/pan
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
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 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