Forum Discussion

bobbob123's avatar
bobbob123
Helper III
4 years ago
Solved

PLOTLY Scatter plot using R in POWER BI

Hi,

 

I have the following dataset.

 

# dataset <- data.frame(EM, HM, SA,S,MA)  #All the elements in this dataframe are integers expect for S which is a string describing the groups.
# dataset <- unique(dataset)
 
I want to create a scatter plot using PLOTLY in R using POWER BI where x= SA and y = HM and legends = S.
 
This is what I have:
 
library(plotly)

fig <- plot_ly(data = dataset, x = ~dataset$SA, y = ~dataset$HM, fill=S)

fig
 
But this is not resulting in a visual. Is there something wrong with my code???
 

4 Replies

  • v-kkf-msft's avatar
    v-kkf-msft
    Community Support

    Hi bobbob123 ,

     

    The most current version of R supported on both Power BI Desktop and the Power BI service is version 3.4.4.

     

    And please try the code:

     

    library(plotly)
    
    plot_ly(data = dataset, x = ~SA, y = ~HM,  type = "scatter", mode = "markers", color =~S)

     
    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.