How to hide axis ticktexts but remain axis tilte

Hello guys, I tried to hide ticktexts but only can do it with a little tricky way: set the color white.
However, the texts still take up space. Is there any better way to hide only ticktexts?

p.s. my data have duplicated datetimes and matches, so I treat them as string.

layout = go.Layout(
    title = 'Overview: Player Age in SF and F<br>' + start_year + ' ~ ' + end_year,
    xaxis = go.XAxis(
        title = 'Time',
#         tickmode = 'array',
#         tickvals = '',
#         ticktext = '',
#         tickfont = go.Font(
#             color = 'rgb(255, 255, 255)'
#         )
    ),
    yaxis = go.YAxis(
        title = 'Age'
    )
)

Hi @ab37695543xs

You can hide the tick text by setting the layout.xaxis.showticklabels property to False.

For example:

import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode()

layout = go.Layout(
    title = 'Overview',
    xaxis = go.XAxis(
        title = 'Time',
        showticklabels=False),
    yaxis = go.YAxis(
        title = 'Age'
    )
)

fig = go.Figure(data=[{'y': [3, 2, 1]}], layout=layout)
iplot(fig)

Hope that helps!

4 Likes