Plotly Bar Graph in R



I am trying to plot a bar graph using plotly library in R. The x-axis goes from the range 0 - 10000, but the y-axis have points only for 100,250,500,1000,1500,2000,2500,5000,10000. But I am getting unnecessary x-axis points for rest of the values which is making the bars very thin. If I could manage the x-axis range with manual values then my bar could look better and I could also increase the width of my bars!

Kindly help me regarding this!

Any help would be appriciated.




@neel- Could you please provide little bit of code which you have tried.


@hinduja1234 - I am using the plotly in the shiny app. Below code is the only plotly part which is being used for the plot.

p <- plot_ly( data = temp_data, x = price_point, y = Price, group = Seller, type = "bar", barmode = "group")

p <- layout(p ,xaxis = list(title = " Number of Units Sold" , range = as.character(sort(unique(as.numeric(subdata4()$price_point)),decreasing = FALSE))),
            yaxis = list(title = " Selling Price ")

Here subdata4() is the subset of data after interactivity with the shiny app, temp_data = subdata4()

I am able to get the plot, but the plot is getting spread because of the missing data points for the x axis like 3000, 6000, 7000, 8000. This has resulted into the thinness of the bars.

I need to remove the extra x-axis price point and it need to be dynamic also, as it will change on every new interaction with the shiny app.