Tuesday, 7 February 2023

Plotly - Remove axis ticks and numbers but keep label

In this MWE, I have a plot with ticks and labels.

fig = go.Figure(data=go.Scatter(x=[2.3], y=[5.3], mode='markers'))
fig.update_xaxes(range=[0,10], constrain="domain",title_text="Some x label",title_font={"size":22,"color":"black"}, showgrid=False)
fig.update_yaxes(scaleanchor="x",scaleratio = 1, range=[0,10], title_text="Some y label",title_font={"size":22,"color":"black"}, showgrid=False)
fig.show()

With ticks

If I remove the grid and the ticks, the x label becomes the plot title and the y label stays far away from the plot. How can I just remove the grid and numbers while keeping the axis labels where they are (or even getting them a bit closer to the axis lines as there are no numbers now)?

fig = go.Figure(data=go.Scatter(x=[2.3], y=[5.3], mode='markers'))
fig.update_xaxes(range=[0,10], constrain="domain",showgrid=False,showticklabels=False,rangemode="nonnegative",
                 title_text="Some x label",title_font={"size":22,"color":"black"})
fig.update_yaxes(scaleanchor="x",scaleratio = 1, range=[0,10], showgrid=False,showticklabels=False,rangemode="nonnegative",
                 title_text="Some y label",title_font={"size":22,"color":"black"})
fig.show()

Without ticks



from Plotly - Remove axis ticks and numbers but keep label

No comments:

Post a Comment