r - Plotly axis labels on multiple lines alignment -


i'm building shiny application plotly horizontal bar charts. data labels pretty long , want break them on multiple lines. works when places <br> on place want break line, alignment of axis labels not go well. see picture below of output (left) , desired plot (right).

plotly output (left) , desired output (right)

below minimal working example. left out shiny part, because expect not affect possible solution.

df <- data.frame(   name = paste0('this pretty long sentence',1:10),   dima = 1:10 )  df$name <- gsub('this pretty long sentence','this a<br>pretty long<br>sentence',df$name)   ## hide axes ax <- list(   title = "",   showline = false,   showticklabels = false,   showgrid = false,   domain = list(0.2, 1) ) ay <- list(   title = "",   zeroline = false,   showline = false,   showticklabels = true,   showgrid = false )  p <- df %>%    plot_ly(x = ~dima,            y = ~name,           type = 'bar',           orientation = 'h'   ) %>%   layout(xaxis = ax, yaxis = ay) p 

help highly appreciated! struggling hours, unable find solution!

this not general can adjust tick position using tickvals, example:

ay <- list( title = "", zeroline = false, showline = false, showticklabels = true, showgrid = false,  tickvals = 0:9 + 0.25 ) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -