Skip to content

Enchance subplot()'s ability to handle pre-specified domain(s) #376

Closed
@talgalili

Description

@talgalili

subplot seems the way to create a scatterplot with marginal histograms in plotly.

However, in order to have it work it needs to:

  1. share the same axes so that all figures will respond to zoom together
  2. we need control over each plots' width.

Example of how it should look like:

# Get some data
library(ggplot2 )
theme_set(theme_classic())
hist_top <- ggplot()+geom_histogram(aes(rnorm(100)))
empty <- ggplot()+geom_blank()
scatter <- ggplot()+geom_point(aes(rnorm(100), rnorm(100)))
hist_right <- ggplot()+geom_histogram(aes(rnorm(100)))+coord_flip()
library(gridExtra)
grid.arrange(hist_top, empty, scatter, hist_right, ncol=2, nrow=2, widths=c(4, 1), heights=c(1, 4))

Which looks like this:

image

And this is how it actually looks like (which should be corrected):

# hide axis ticks and grid lines
eaxis <- list(
  showticklabels = FALSE,
  showgrid = FALSE,
  zeroline = FALSE
)

p_empty <- plot_ly(filename="r-docs/dendrogram") %>%
  # note that margin applies to entire plot, so we can
  # add it here to make tick labels more readable
  layout(margin = list(l = 200),
         xaxis = eaxis,
         yaxis = eaxis)

subplot(hist_top, p_empty, scatter, hist_right, nrows=2, margin = 0.01)

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