plotly.js
plotly.js copied to clipboard
Better log axis tick labeling with less label overlap for scatter plots
Swap small single-digit subtick labels with normal-size multi-digit labels, but only at positions 2, 3, 5 and 7 to avoid text overlapping, and depending on subtick text length.
Details see https://stackoverflow.com/questions/70926979

The patch changes the default behaviour of tick labeling and so breaks some tests. I would actually prefer introducing a new tickformat, e.g. "D3", to show this behaviour and not break existing behaviour. But to implement that is beyond my abilities ... any help?
Any comments, progress, review? Anything I need to do to help merging this? Yes, there are some failing tests, but this is obviously because I am (slightly) changing Plotly's behaviour, intentionally ... for the better, I hope.
Hi @jensb - thank you, this is definitely a mode a lot of people will like! But it's a big enough change that I don't think we can make it the default without a major version bump. I'd like to propose we add a new attribute like ax.loglabels (name and values open for discussion) that would default to 'small digits' (the current behavior) but also support 'full value' (your addition here). This way we would still automatically switch between linear tick labels, D1, D2, and 1 or more complete orders of magnitude as the axis range changes - your changes apply to both D1 and D2 modes in this evolution.
Also two issues I notice:
- In your gif above you can see that the 1's are shifted down still - this shift should be removed.
- We'll need to figure out how to implement this a little deeper in the stack, without altering
tickformatorhoverformat- because users will still want to use those, at leasthoverformat.
Thanks for kicking this off, and apologies for the slow review!
Thank you! Yes, I fully agree with all your comments, and I'd be happy to review / test any patches and also help with development. To start this by myself I may need some guidance though. I also tried to make the 1s bold instead of shifting them down which would increase usability further, but my attempts didn't work. BTW it seems Github has a maximum allowed frame count for GIFs, the uncut GIF is on Stackoverflow, there you can see how my Patch acts when zooming further in.
Adding an attribute is fairly easy, but you need to know where to do what. First the attribute needs to be defined, this one should probably go somewhere around here. Then in the supplyDefaults step we need to set that attribute only when it applies - that would be next to this block with the condition if(axType === 'log')
At that point you can use it, and I think the file you've already been working in is the only one you'll need to change.
After that we'll want some tests, but we can talk about that later :)
Closing. Please see new PR #7468 instead.