Closed
Description
subplot seems the way to create a scatterplot with marginal histograms in plotly.
However, in order to have it work it needs to:
- share the same axes so that all figures will respond to zoom together
- 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:
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)