plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Better log axis tick labeling with less label overlap for scatter plots

Open jensb opened this issue 3 years ago • 5 comments
trafficstars

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

animation

jensb avatar Feb 15 '22 19:02 jensb

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?

jensb avatar Feb 15 '22 19:02 jensb

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.

jensb avatar Mar 09 '22 17:03 jensb

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 tickformat or hoverformat - because users will still want to use those, at least hoverformat.

Thanks for kicking this off, and apologies for the slow review!

alexcjohnson avatar Mar 09 '22 20:03 alexcjohnson

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.

jensb avatar Mar 09 '22 21:03 jensb

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 :)

alexcjohnson avatar Mar 09 '22 22:03 alexcjohnson

Closing. Please see new PR #7468 instead.

archmoj avatar Jul 15 '25 02:07 archmoj