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

Restrict axis ticks labels to only show int values

I have a plot with a y axis

It should only show integer values such as 1,2,3,4

Unfortunately when I zoom in floats are displayed (1.5,2.5,3.5)

Is there a way of telling plotly to only display ints

I tried using a list of predefined tickvals but this list is too long when zoomed out fully than the labels overlap



You could try using tickformat like in

This is nice but it produces multiple numbers which are the same.

β€œ1 1.5 2” turns into β€œ1 1 2”

Ideally I was looking for a method of turning β€œ1 1.5 2” into just β€œ1 2”


There’s probably a way to do this. You can play around with all the possible format settings on

Thanks etienne your recommeded link worked very well

The format that removes rounded ints was d3.format(",d")

The graph looks much nicer now


In python, along:

fig = Figure(
    data = data,
    layout = Layout(
        yaxis={'tickformat': ',d'},