Search code examples
rbar-chartcropplotlyaxes

R plotly x axes are cropped


Using R plotly I'm plotting a bar chart, my factors are quite long so I made this transformation on the x axe:

tickangle = -45

Thing is, now my factors are cropped:

enter image description here

Any idea on how to automatically select a height to my plot so my factors won't be cropped?


Solution

  • You can use the margin argument inside the layout function:

    layout(margin = list(l = 0, r = 0, b = 100, t = 0)
    

    where:
    l = left
    r = right
    b = bottom
    t =top