Skip to content

Conversation

@lucasb-eyer
Copy link
Contributor

(note: builds on top of https://github.com/mpld3/mplexporter/pull/72/files so contains that commit, which I'll make disappear after merge+rebase)

This will allow to render both major and minor gridlines in mpld3, which
fixes the following issue: mpld3/mpld3#527

As per usual, disclaimer that I co-developed this with gpt-5.1-codex,
having it figure out the issues and give implementation recommendations,
with me testing, verifying, and tidying up the code.

Here's what it has to say, especially wrt the change in API call:

  • include minor tick values/length and minor grid style in axis props so minor ticks/grids render in mpld3
  • read grid color/linewidth/linestyle from tick kwargs (and rcParams fallback) instead of inspecting gridlines[0], avoiding the get_gridlines(which=…) API that isn’t available on matplotlib 3.10”

Rationale for the kw/rc approach:
Axis.get_gridlines() doesn’t accept which on matplotlib 3.10, so probing gridlines[0] for minor/major fails. Pulling style from the tick keyword dict (which matplotlib populates with grid_* fields when you call ax.grid(...)) plus
rcParams defaults gives the same style without needing get_gridlines(which=…), keeping compatibility and matching user-set grid styles.

(I verified, indeed get_gridlines does not allow specifying which ones - seems like an omission in matplotlib API to me)

Screenshot of it working, blue are the minor ticks. Note the minor tick labels are not yet shown, I'll work on that later - maybe updating this PR in-place, or with a new one on top, depending on how simple/complex it is.
image

lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Dec 1, 2025
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Dec 2, 2025
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Dec 2, 2025
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Dec 3, 2025
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
@vladh
Copy link
Member

vladh commented Jan 2, 2026

Looks like there's a conflict, will leave it for you to take a look at!

@lucasb-eyer
Copy link
Contributor Author

Needed a rebase, done, should be good now.

This will allow to render both major and minor gridlines in mpld3, which
fixes the following issue: mpld3/mpld3#527

As per usual, disclaimer that I co-developed this with gpt-5.1-codex,
having it figure out the issues and give implementation recommendations,
with me testing, verifying, and tidying up the code.

Here's what it has to say, especially wrt the change in API call:

- include minor tick values/length and minor grid style in axis props so minor ticks/grids render in mpld3
- read grid color/linewidth/linestyle from tick kwargs (and rcParams fallback) instead of inspecting gridlines[0], avoiding the get_gridlines(which=…) API that isn’t available on matplotlib 3.10”

Rationale for the kw/rc approach:
`Axis.get_gridlines()` doesn’t accept `which` on matplotlib 3.10, so probing `gridlines[0]` for minor/major fails. Pulling style from the tick keyword dict (which matplotlib populates with `grid_*` fields when you call `ax.grid(...)`) plus
`rcParams` defaults gives the same style without needing `get_gridlines(which=…)`, keeping compatibility and matching user-set grid styles.

(I verified, indeed get_gridlines does not allow specifying which ones - seems like an omission in matplotlib API to me)
@lucasb-eyer
Copy link
Contributor Author

(the conflict was the renaming of _dasharray_from_linestyle to dasharray_from_linestyle which I had to change here)

@vladh
Copy link
Member

vladh commented Jan 2, 2026

Oops — thank you!

@lucasb-eyer
Copy link
Contributor Author

wanna hit merge?

@vladh
Copy link
Member

vladh commented Jan 2, 2026

Will test ASAP!

@lucasb-eyer
Copy link
Contributor Author

ah, you were just on a streak so I was wondering :D Take your time.

lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Jan 3, 2026
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Jan 7, 2026
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Jan 17, 2026
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
lucasb-eyer added a commit to lucasb-eyer/mpld3 that referenced this pull request Jan 17, 2026
The js-side of mpld3/mplexporter#73 and fixes mpld3#527
Also adds some tests for minor-grid.

It seems that the uglify is getting tripped up by `??`, so we should
consider upgrading it, because a little chunk of this code could be
quite a bit less verbose with that.

Anyways, as usual disclaimer about having co-developed this with
gpt-5.1-codex, but also tested and carefully reviewed/cleaned it.

Here's what it has to say:

- carry filtered minor tick values/length into axis props and draw a separate minor grid/tick layer
- streamline axis getGrid tick selection and style passthrough to grids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants