Assuming generating a scatter plot with ggplot
which has the gradient color and shape based on the variables in mtcars
built-in database in R
.
using the following script adopted from Nathan Day in my previous question:
library(ggplot2)
plot<- ggplot(mtcars, aes(mpg, hp, fill = cyl, size = cyl)) +
geom_point(shape = 21, stroke = 2) +
scale_fill_gradientn(colours = rainbow(7)) +
scale_size(range = c(2,6))
we would get the following plot
Now, when I am trying to convert it to ploty
using the following script :
library(plotly)
ggploty (plot)
I would get the following plot which is basically change the color and I loose my gradient colour featur in my ggplot
as can be seen in previous plot generated by ggplot
.
Of course I would get the interactive image BUT I was not able to upload in this page so I just take a static image of the generated ploty
image.
Can you please help me to know how I can keep the original format of ggplot
when converting to ploty
by ggploty
command?