Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement options to draw minor ticks and grid lines in Cartesian subplots #6166

Merged
merged 60 commits into from
May 2, 2022

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Apr 7, 2022

Resolves #903.

@plotly/plotly_js

minor: {
tickmode: tickmode,
nticks: nticks,
tick0: tick0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to support tick0 here? Strange things could happen, which may be fine if (a) axis.minor.tick0 inherits from axis.tick0 (even if axis.tick0 is set during autotick as in the case of week ticks), and (b) we test out the relevant cases and ensure we like the results.

I guess this is the main thing we want to test in jasmine, right? First the standard cases, where you provide major tick settings and various combinations of minor nticks, dtick, and tick0 and verify that the correct minor ticks are generated.

Even without explicit tick0 there are questions about what to do when dtick is not an integer multiple of minor.dtick - do we keep the minor tick spacing consistent, or do we start fresh from every major tick? Presumably the former, even though that means two minor ticks will straddle one major. But I could certainly see wanting this for example to put week minor ticks with month major ticks.

@alexcjohnson
Copy link
Collaborator

Minor drawing issues:
1 - the inside minor and outside major ticks don't meet, there's a little gap:
Screen Shot 2022-04-13 at 14 52 22

2 - Y minor gridlines are on top of X major, can we put them behind?
Screen Shot 2022-04-13 at 15 03 07

majorDtick.charAt(0) === 'M'
) {
if(majorDtick === 'M24') {
ax.dtick = 'M12';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj I love the new auto-minor algorithm! When you simply turn on minor ticks it's perfect as far as I can see 🏆 😍

That said I think these date cases here are still a little too hard-coded if you stray from full auto mode. For example if I set minor.nticks=12 or larger I'd expect year ticks to give one-month minor, 2-year ticks to give 2-month minor, etc. If I do that right now, 2-year ticks get 1-year minor, but when you zoom out to 5-year ticks you DROP to (the expected) 6-month minor ticks.

}
}
} else {
dist /= nt || 7;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small (minor? 😏 ) point: on linear axes, if I want minor.dtick===dtick/10 I don't get this with minor.nticks: 10, I have to go to 11

Also, I was expecting if I provided major dtick and tick0 plus minor.dtick, that minor.tick0 would be inherited from tick0 - but it seems unless I explicitly provide it to match, minor.tick0 reverts to the default.

Screen Shot 2022-04-26 at 09 39 38

@alexcjohnson
Copy link
Collaborator

Noting that outside ticks appear to be plotted by 0.5 pixel outside the plotting area, there is still 0.5 pixel gap between the two.

Definitely better, and we can leave all of this (including the 0.5px outside gap ^^) as a bug to come back to later if you prefer, since it was already there with major ticks only. But whenever we do address it, it seems like there's still some condition where the inside ticks don't quite reach as far as they should. See mirror-all-vs-allticks where in the green subplot the left and top inside ticks have a gap with the axis line, but the right and bottom do not.

Screen Shot 2022-04-26 at 10 40 23

@archmoj
Copy link
Contributor Author

archmoj commented Apr 29, 2022

Minor drawing issues: 1 - the inside minor and outside major ticks don't meet, there's a little gap: Screen Shot 2022-04-13 at 14 52 22

FYI - I opened #6173 which would be addressed in a separate PR to avoid several baseline changes unrelated to this feature PR.

var positions =
ax._vals
.filter(function(d) { return d.minor; })
.map(function(d) { return d.x; });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonblocking: the date and log tests would be more readable if the values were in data format, ie I think ax.l2d(d.x)

looks confusing to have minor ticks 2,5,10,20,50, so drop to
just the orders of magnitude.
D1 is fine though, if you ask for that many minor ticks!
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're finally there! Thanks for all the hard work @archmoj, this one was definitely more involved than it originally appeared!
💃 🕺 🕺 🕺 💃 🕺 🕺 🕺 💃 🕺 🕺 🕺 💃

@archmoj archmoj merged commit ad6fe93 into master May 2, 2022
@archmoj archmoj deleted the minor-ticks branch May 2, 2022 18:19
@etpinard
Copy link
Contributor

etpinard commented May 4, 2022

Great feature.

Congrats @archmoj !

@archmoj
Copy link
Contributor Author

archmoj commented May 5, 2022

Great feature.

Congrats @archmoj !

Thanks very much @etpinard.
It wasn't possible without @alexcjohnson help.

kMutagene added a commit to plotly/Plotly.NET that referenced this pull request Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Major and minor ticks
4 participants