Smoothed plot in plolty

Hi,

I am trying to create a smoothed heatmap in plolty; however, when using ggplot, the smoothness does not seem to pass when using ggplotly.

library(gplots)
library(plotly)

a <- data.frame( x=rnorm(20000, 10, 1.9), y=rnorm(20000, 10, 1.2) )
b <- data.frame( x=rnorm(20000, 14.5, 1.9), y=rnorm(20000, 14.5, 1.9) )
c <- data.frame( x=rnorm(20000, 9.5, 1.9), y=rnorm(20000, 15.5, 1.9) )
data <- rbind(a,b,c)

p <- ggplot(data, aes(x=x, y=y) ) +
stat_density_2d(aes(fill = ..density..), geom = "raster", contour = FALSE, interpolate =T) +
scale_fill_distiller(palette= "Spectral", direction=1) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
theme(legend.position='none'
)

ggplotly(p)

any suggestions?

I read that https://cran.r-project.org/web/packages/heatmaply/vignettes/heatmaply.html
is a specialised plotly implementation for heatmap, perhaps it has better performance ?

Hi Nirgrahamuk,

Thanks for the suggestion, I have managed to fix it, you can see below the difference by using heatmap option on its own and after using extra options.

plot_ly(z = volcano, type = "heatmap", colorscale = 'Jet')

plot_ly(z=volcano, colorscale = 'Jet', type="heatmap", zsrc="plotly.js:638:", zsmooth="best")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.