ENH: Support minor grid in Axes3D#31527
ENH: Support minor grid in Axes3D#31527EncryptedDoom wants to merge 2 commits intomatplotlib:mainfrom
Conversation
66a640c to
507de28
Compare
`ax.grid(which='minor')` was silently ignored on Axes3D. This commit adds full minor grid support by extending grid(), adding draw_minor_grid() to axis3d.py, and adding a test.
507de28 to
8ddadfc
Compare
|
I think this needs a lot of work to get to a robust implementation - you're duplicating a good amount of logic, only applying 3 grid style kwargs, and there is duplicated / unused code in your diff. Given these issues and the use of AI to plan the implementation I'm going to mark this for a quick close. But please feel free to ping me if you bring it to a ready state and I can remove the tag & review more thoroughly then. |
|
⏰ This pull request might be automatically closed in two weeks from now. Thank you for your contribution to Matplotlib and for the effort you have put into this PR. This pull request does not yet meet the quality and clarity standards needed for an effective review. Project maintainers have limited time for code reviews, and our goal is to prioritize well-prepared contributions to keep Matplotlib maintainable. Matplotlib maintainers cannot provide one-to-one guidance on this PR. However, if you ask focused, well-researched questions, a community member may be willing to help. 💬 To increase the chance of a productive review:
As the author, you are responsible for driving this PR, which entails doing necessary background research as well as presenting its context and your thought process. If you are a new contributor, or do not know how to fulfill these requirements, we recommend that you familiarize yourself with Matplotlib's development conventions or engage with the community via our Discourse or one of our meetings before submitting code. If you substantially improve this PR within two weeks, leave a comment and a team member may remove the |
|
@scottshambaugh Thank you for the detailed feedback — this is very helpful. I'll refactor the implementation to extract the shared grid-drawing logic into a common method, pass through the full set of line properties rather than just the three kwargs, and clean up the duplicated code in the diff. I'll ping you once it's ready for another look. |
|
Those were specific points, but please focus on understanding how the 2D case works and how that can be mapped in a robust way onto the 3D case. Also, your response seems to be AI generated. Do not use AI to assist in writing comments except for direct translation to English. Can you please clarify if you did here? |
|
Thank you for outlining the what I need to work on and I will ensure I thoroughly understand the 2D implementation before making necessary changes to the code. |
PR summary
ax.grid(which='minor')was silently ignored onAxes3D— thewhichparameter was not handled at all, making it impossible to display minor gridlines on 3D plots without manual workarounds usingax.plot().This PR adds minor grid support for 3D axes by:
Axes3D.grid()to acceptwhich('major','minor','both') and storing minor grid state in_draw_minor_gridand_minor_grid_kwargsAxes3D.clear()Axis.draw_minor_grid()inaxis3d.pywhich reads minor tick positions fromget_minorticklocs()and draws L-shaped segments with independent line properties, mirroring the existingdraw_grid()implementationaxis.draw_minor_grid(renderer)inAxes3D.draw()after the major grid loopMinor gridlines default to half the major linewidth with the same color and linestyle, but all properties can be overridden via kwargs.
Closes #31467
Minimum example:
Example output:

AI Disclosure
I used Claude (Anthropic) to help plan the implementation approach, understand the existing
draw_grid()structure. The code changes were written and verified by me.PR checklist