Black Lives Matter. Please consider donating to Black Girls Code today.

Prevent last item from being at edge of chart

I’m wondering if there’s a way to prevent the last item in a string based x axis from being right up on the edge of the chart. As you can see when this is the case, if there is a long name of that column it gets cut off.

I don’t want to solve the problem by adding a margin.r to the chart’s layout. I’d rather figure out a way to keep the chart full width, but limit where plotly places the last column.

Thank you!

Another way would be by setting the xaxis.range: http://codepen.io/etpinard/pen/VjZRpb

Note that categorical axes are mapped to integer values starting from 0 with step 1.