I want to increase the width of the Y-axis of a plotly horizontal bar chart. Right now, text falls of the plot because the y axis is too narrow.
You can see the same happening on the examples page of Plotly, where the categories are simple not readable very well.
I can't find a way to increase width. Help is highly appreciated!
Example code:
library(plotly)
p <- plot_ly(x = c(20, 14, 23),
y = c('long string which is not readable',
'orangutans (not readable)',
'monkeys'),
type = 'bar',
orientation = 'h')
Plotly hid this quite well... You can change this in the layout of the xaxis, under domain.
The following will work:
ax <- list(
domain = list(0.2, 1)
)
p <- plot_ly(x = c(20, 14, 23),
y = c('long string which is not readable',
'orangutans (not readable)',
'monkeys'),
type = 'bar',
orientation = 'h') %>%
layout(xaxis = ax)
General tip: Plotly has an online editor, where you can export a JSON object, which contains all the settings. Then, searching through that object might help the find the right settings.
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