I'd like to combine 2 different posts of mine - Set marker size based on coordinate values, not pixels, in plotly R - and - add_trace in plotly, which trace to use for my particular graph - into one here.
At a high level, I'd like to create interactive hexagonal heatmaps in R using plotly. I am considering the following two approaches:
- using scatter trace with markers
- using heatmap trace with hexagons
I am running into difficulties with both approaches. For the heatmap trace, I cannot find a parameter to change the shapes from squares to hexagons (does this exist?). For the scatter trace, I cannot fix the size of the markers to the values of the axes (only to pixel counts), and therefore the shapes do not scale the same size when I increase the size of the graph (see example at bottom).
and
Any thoughts on this would be appreciated!
EDIT: here's an example of my code using scatter trace with markers:
mydf <- data.frame(x = rep(1:20, times = 20), y = rep(1:20, each = 20),
thesize = 15)
plot_ly(mydf) %>%
add_trace(x = ~x, y = ~y, type = 'scatter', mode = 'markers',
marker = list(symbol = 'hexagon', size = ~thesize, opacity = 0.6))
# note that the size is 15 pixels. I'd prefer that the size is pinned to values on the X and/or Y axis.