plotly / plotly/plotly.R

subplot() doesn't account for dual axes

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

Nobody has claimed this yet.

difficulty: high priority: low
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

I think there is something wrong with the subplot function when there is yaxis2

I tried to use subplot with 2 plots that have yaxis2. Each plot looks like this:
image

foo_plot <- function(n) {
  x <- rnorm(n)
  den <- density(x)
  p <- plot_ly()
  p <- add_trace(p, x=x, type="histogram", name="Histogram",
    marker=list(line=list(color="#000", width=1), color="#555"))
  p <- add_trace(p, x=den$x, y=den$y, yaxis="y2", name="Density",
    type="scatter", mode="lines", line=list(color="#222"))
  p <- layout(p,
    yaxis2=list(overlaying="y", side="right", rangemode="nonnegative",
      showgrid=F, showline=T, ticks="outside"),
    yaxis=list(showline=T, ticks="outside"))
  return(p)
}

p <- subplot(foo_plot(1000), foo_plot(1000), nrows=2, shareX=F, shareY=F)

The density curves were missing when I merge the two plots.
image

This is the result of sessionInfo()
image

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 running the issue's foo_plot and subplot example, comparing each plot with the combined two-row result. Trace subplot's handling of yaxis2 and verify that both density curves remain visible after merging; done means dual-axis traces render correctly in the combined plot.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.