Skip to content

subplot() doesn't account for dual axes #1203

Open
@TriLe965

Description

@TriLe965

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions