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

Logarifmic axis minor tick lables removing

Hi!
Is it possible to make the correct log Plot like

I want to remove minor ticks labels on the y-axis. My plot is

My code

fig = px.bar(ICP, x = 'Name', y = 'au', title='ICP Gold, %')
fig.update_yaxes(type="log")
fig.update_layout(
    template="plotly_white",
    #title="Us influence on CO conversion",
    xaxis_title= "Type",
    yaxis_title="log, [%]",
    font=dict(
        family="Courier New, monospace",
        size=14,
        color="black"
    )
)
fig.show()

There are some same questions in this community page but there are no answers: example

Hi @Ilia, plotly displays a ticks label for every tick line, but you can override this by passing directly the tick labels. Below is an example of how to do this (for the x axis), please also see https://plot.ly/python/axes/#enumerated-ticks-with-tickvals-and-ticktext

import numpy as np
import plotly.express as px
x = np.linspace(0, 1, 200)
fig = px.scatter(x=x, y=x**3)
tickvals = np.concatenate((np.arange(0.004, 0.01, 0.001),
                           np.arange(0.01, 0.1, 0.01),
                           np.arange(0.1, 1.1, 0.1)))
ticktext = [str(val) if val in [0.01, 0.1, 1] else '' for val in tickvals]
fig.update_xaxes(type="log", tickvals=tickvals, ticktext=ticktext)
fig.update_yaxes(type="log")
fig.show()

1 Like

Dear, @Emmanuelle. After using your solution got Y title “bug”

my code

fig = go.Figure(data=[go.Bar(x = ICP['Name'], y = ICP['au'],
                                text=round(ICP['au'], 3),
                                textposition='auto')])
fig.update_yaxes(type="log", showgrid=True, dtick=1)
#your method
tickvals = np.concatenate((np.arange(0.004, 0.01, 0.001),
                           np.arange(0.01, 0.1, 0.01),
                           np.arange(0.1, 1.1, 0.1),
                           np.arange(1, 10.1, 1)))
ticktext = [str(val) if val in [0.01, 0.1, 1, 10] else '' for val in tickvals]
fig.update_yaxes(type="log", tickvals=tickvals, ticktext=ticktext, showgrid=True)


fig.update_layout(
    template="simple_white",
    #title="Us influence on CO conversion",
    xaxis_title= "Type",
    yaxis_title="log, [%]",
    font=dict(
        size=14,
        color="black")
)
fig.write_image("images/ISP.png", width=1000, height=600, scale=2)

fig.show()

Do you have any ideas about how to fix it?