I am trying to develop shiny app which renders plot using plotly. I am able to get the plot using an example for plotly in shiny. But my graph does not look good. I am using ggplot2 for ploting the graph and then converting it to plotly using gg2list() and stored in a variable gg.
` output$trendPlot <- renderGraph({
xaxislimits=as.character(sort(unique(as.numeric(subdata4()$price_point)),decreasing = FALSE))
p <- ggplot(data=subdata4(), aes(x=price_point, y=Price, fill=Seller)) +
geom_bar(stat="identity",position=position_dodge() ) +
xlab("Number of Units Sold") + ylab("Selling Price ")
gg <- gg2list(p)
# make edits with plotly syntax
gg$layout <- list(legend = list(
x = 1,
y = 1,
bgcolor = "transparent"))
# Send this message up to the browser client, which will get fed through to
# Plotly's javascript graphing library embedded inside the graph
return(list(
list(
id = "trendPlot",
task = "newPlot",
data = gg$data,
layout= gg$layout
)
))
})
})`
But the plot is not good. And i dont understand whether to plot using ggplot2 then convert to plotly or us plot_ly() directly?
Kindly help me!
Any help will be appreciated.