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

Axis range for string ticks

How can I set a range for an axis if the ticks are only strings?

Like x = [“a”, “b”, “c”] and I want to set the range to only initially show “b” and “c”.

Thanks.

Categorical axes use integers starting from 0 as their range.

So in your case, simply set layout.xaxis.range = [1, 2].