plotly.py
plotly.py copied to clipboard
Minor Ticks Array update mode not working
Hi all,
I was experiencing some issue with setting minor ticks in a graph-objects figure.
Originally, i tried to use a log scale with the go.Violin package and ran into errors. Hence i tried to transform my data beforehand and plot via violins. This way though i need to manually set the ticks for the axis. Doing so i experienced the following issue:
the plotly.graph_objects.layout.xaxis.Minor object lets one set the tickmode to "array" and specify the tickvals is possible. Although there is a reference to ticktext in the documentation (https://plotly.com/python-api-reference/generated/plotly.graph_objects.layout.xaxis.html#plotly.graph_objects.layout.xaxis.Minor) in the tickmode and tickvals entries, it is not listed as class method. Consequently using it throws an error. As a result i was not able to find how i can conveniently set custom minor tickmarks.
To reproduce the issue consider the following script:
fig = go.Figure()
fig.add_trace(
go.Scatter(x=[], y=[])
)
fig.update_layout(
xaxis=dict(
range=(0,4), tickmode="array", tickvals=[0,2,4], ticktext=[0,2,4], minor=dict(
ticks="outside", tickmode="array", tickvals=[1,3], showgrid=True
)
),
template="plotly"
)
fig.show()
Which will produce the following image consisting the minor grid and tickmarks :
Inserting ticktext will raise error
fig = go.Figure()
fig.add_trace(
go.Scatter(x=[], y=[])
)
fig.update_layout(
xaxis=dict(
range=(0,4), tickmode="array", tickvals=[0,2,4], ticktext=[0,2,4], minor=dict(
ticks="outside", tickmode="array", tickvals=[1,3], showgrid=True, ticktext=[1,3]
)
),
template="plotly"
)
fig.show()
ValueError: Invalid property specified for object of type plotly.graph_objs.layout.xaxis.Minor: 'ticktext'
At this point i am unsure on how to set the text and certain that at least the documentation should be changed.
hi @schmidt-jo Thank you for bringing this up.
Unfortunately, adding labels to minor tickmarks is not possible.
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson