talgalili / heatmaply

Interactive Heat Maps for R Using plotly
377 stars 73 forks source link

grid_size seems to do nothing #299

Open mcsimenc opened 9 months ago

mcsimenc commented 9 months ago

I would like to make the smallest point smaller when using node_type = "scatter". As I understood the description in the documentation, grid_size controls this, however different values for this parameter seem to have no effect.

Large value for grid_size

# Make data
mat1 = matrix(rexp(100), nrow = 10, ncol = 10)
mat2 = matrix(c(rexp(90, rate = 1), rep(0, 10)), nrow = 10, ncol = 10)

heatmaply(
  x = mat1,
  point_size_mat = mat2,
  grid_size = 1e3,
  node_type = "scatter",
  plot_method = "ggplot"
)
image

Small value for grid_size

heatmaply(
  x = mat1,
  point_size_mat = mat2,
  grid_size = 1e-3,
  node_type = "scatter",
  plot_method = "ggplot"
)
image

Any ideas what I might be doing wrong or is going on?

alanocallaghan commented 9 months ago

Only when using a fixed point size, and not when mapping point size to point_size_mat

mcsimenc commented 9 months ago

Got it, thank you.

My use case is in emulating a plot made with ggplot mapping point size like geom_point(mapping = aes(size = ..., but the mapping function seems like it may be different than for heatmaply.

For example, here are four plots using the same data with different point size mappings:

heatmaply(plot_method = "ggplot" ...:

image

heatmaply(plot_method = "plotly" ...:

image

ggplot + geom_point(aes(size = ...:

image

ggplot + geom_point(aes(size = ... + ggplotly

image

I would like to use plot_method = ggplot, but the difference in size mapping is greatest between ggplot + geom_point(aes(size = ... and heatmaply(plot_method = "ggplot" ....

Do you know if there are any tweaks that can be made to approach it using heatmaply?

alanocallaghan commented 9 months ago

Truthfully no, as far as I can tell the call to ggplot2 should basically be equivalent to ggplot(data) + geom_point([...], size=size_var).

If you post reproducible code for the example plots you showed in the last comment, I'll have a look