ggplotwithyourdata icon indicating copy to clipboard operation
ggplotwithyourdata copied to clipboard

added code for plotly

Open winsonfzyang opened this issue 7 years ago • 4 comments

Hello! I think I might know a way to allow plotly to work on your app. you would have to add this to server.R:

output$plotly.plot <- renderPlotly({ ggplotly(plotObject()) })

output$ui_plotly <- renderUI({ plotlyOutput('plotly.plot', width = "100%" ,height = input$height) })

But doing that your box plots will not work because when you have no input in Groups, your group is an empty column, and plotly cannot read it.

geom_boxplot(aes(group=NULL)

My suggestion to get it working is to replace NULL with input$x:

geom_boxplot(aes_string(group=input$x)

winsonfzyang avatar Mar 23 '18 05:03 winsonfzyang

Thanks.Will have a look. But there is use cases where you don't want the group to be x for example you might want x and the factor color you chose. Ggplot automatically choose the combination of factors and I have this to be able to have boxplots and overlay a median lines colored by a factor.Plotly is in part implemented but indeed having more things working is desirable. From: [email protected]: March 23, 2018 7:27 AMTo: [email protected]: [email protected]: [email protected]: [smouksassi/ggplotwithyourdata] added code for plotly (#19) Hello! I think I might know a way to allow plotly to work on your app. you would have to add this to server.R: output$plotly.plot <- renderPlotly({ ggplotly(plotObject()) }) output$ui_plotly <- renderUI({ plotlyOutput('plotly.plot', width = "100%" ,height = input$height) }) But doing that your box plots will not work because when you have no input in Groups, your group is an empty column, and plotly cannot read it. geom_boxplot(aes(group=NULL) My suggestion to get it working is to replace NULL withinput$x: geom_boxplot(aes_string(group=input$x)

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

smouksassi avatar Mar 24 '18 09:03 smouksassi

Dear winsonfzyang , Can you show some example plotly outputs you would like the ggquickeda ( new package name to produce ?) will repoen in the new repo thanks

smouksassi avatar Apr 16 '18 07:04 smouksassi

Hello smouksassi, Maybe a scatterplot or box plot for a start will be good. I've made my own modifications to your app for my usage, and I think this will work

winsonfzyang avatar Apr 18 '18 07:04 winsonfzyang

Dear winsonfzyang, please comment on the issue with ggquickeda the new version of this package just submitted to CRAN. Plotly will work whenever you remove the ignore mapped grouping and you map a group explicilty but then you lose the automatic grouping that ggplot do under the hood.

Using the built in sample_data I am using Gender as x variable and conc as y variable and Gender as Colour B, Group By and Fill by: and we split column by Race explicitgrouping

now suppose you want another plot morethanonegroupneeded

when grouping is not specified ggplot knows that we wnat to group by the combination of x and color

this where Plotly will not work unless you do the Race_gender group and group by it as below you will get the plotly but it will not be dodged probalby because it is automatic in ggplot

morethanonegroupneededplotly

This illustrate why just grouping by x variable might not be enough and this app was designed with ggplot first and foremost in mind. I would like to make it more plotly compatible by writing directly in plotly as ggplotly has some limitations.

smouksassi avatar Apr 19 '18 06:04 smouksassi