Format ticks: i.e. 200 to 20. One zero less

Hi community,

I want the plot axes tick to be formatted for example from ‘200’ to ‘20’. My code is:

dx, dz = 100, 100
x = np.arange(0, 60000, dx)
z = np.arange(0, 30000, dz)

[zz, xx]= np.meshgrid(z, x, indexing='ij')

vel = 1000 + 0.032 * zz

fig = px.imshow(vel, labels=dict(x="x[km]", y="z[km]", color="Velocity (m/s)"),

fig.update_layout(xaxis_title='x [km]', yaxis_title='z [km]', title='Raytrace')

The result plot is:

I want the plot axes to have a zero less. For example: the y-axis ticks be [0, 5, 10, 15, …] instead of [[0, 50, 100, 150, …]]

If anyone can help me out here, I’ll be very greatful.


hi @esia2019 ,

You could add a fixed range like this:

    tickvals=[100*i for i in range(6)],
    ticktext=[10*i for i in range(6)])

EDIT: according to this stackoverflow post, you can obtain the autorange the following code snippet:

full_fig = fig.full_figure_for_development(warn=False)

This worked for me, but the kaleido package has to be installed.

1 Like