Plotly is one of the most useful plotting packages in R, but I am facing a very basic issue with it.
When I am drawing a barplot , it looks ok in a small screen, but as soon as I resize the window , it covers the whole window, making it ugly.
As my requirement is dynamic , number of bars on the plot changes, but I want to keep the bar width look decent.
But when it gets resized
the code which I am using to plot the barplot is simple and I hope need not be explained . The width option doesnt make any impact on the graph.
Am I missing anything?
ds <- as.data.frame(matrix(c('some_name',2300),nrow = 1,ncol=2))
colnames(ds) <- c('name','value')
plot_ly(ds,x=name,y=value,type='bar') %>% layout(width = 0.1)
There is no such option called bar size in ploty, but you can use bargap option in the layout.
Yes, you need to set the autosize=F
. So correctly it should be :
plot_ly(ds,x=name,y=value,type='bar') %>% layout(width = 100, autosize=F)
Another option is to set width and height in the plotlyOutput
(keeping the autosize=T
):
plotlyOutput("plot", height="700px", width="200px")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With