mpl_to_plotly: map enumerated tick labels to Plotly tickvals/ticktext by willtryagain · Pull Request #5349 · plotly/plotly.py

@willtryagain

Hi,
This fixes #5059 preserving axis labels while converting matplotlib plots.

Code PR

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the code generator and not the generated files.
  • I have added tests or modified existing tests.
  • For a new feature, I have added documentation examples (please see the doc checklist as well).
  • I have added a CHANGELOG entry if changing anything substantial.
  • For a new feature or a change in behavior, I have updated the relevant docstrings in the code

.

@willtryagain

@willtryagain willtryagain changed the title matplotlib tick labels add matplotllib: map enumerated tick labels to Plotly tickvals/ticktext

Sep 18, 2025

@willtryagain willtryagain changed the title matplotllib: map enumerated tick labels to Plotly tickvals/ticktext mpl_to_plotly: map enumerated tick labels to Plotly tickvals/ticktext

Sep 18, 2025

@gvwilson

thanks @willtryagain - I'll try to find someone to review this in the next work cycle.

@willtryagain

Hi @emilykl ,

This change maps enumerated tick labels to Plotly tickvals/ticktext in mpltools.prep_ticks. I realize it could be viewed as risky if applied too broadly (e.g., forcing array-mode on numeric axes). I only tested locally on a simple script.
Would using a more tighter check and adding tests make it easier to review? Let me know if you have any suggestions.