Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tacaswell
Copy link
Member

PR Summary

Closes #9593

This documents the exact call chain so we can leave the monkey patching route implicit ;)

@tacaswell tacaswell added this to the v3.8.0 milestone Feb 9, 2023
@oscargus
Copy link
Member

oscargus commented Feb 10, 2023

Makes sense to add the same to

# func used to format z -- fall back on major formatters
self.fmt_zdata = None

?

This may just as well go in 3.7? (I guess it would if there was a 3.7-doc? Edit: no, not in 3.7-doc as it also changes the lib-files, but still...)

@ksunden
Copy link
Member

ksunden commented Mar 3, 2023

Do we want to get this in prior 3.7.1, which we are looking to tag today?

@QuLogic QuLogic modified the milestones: v3.7.1, v3.7.2 Mar 4, 2023
@tacaswell tacaswell changed the title DOC: document fmt_xdata and fmt_ydata DOC: document fmt_xdata, fmt_ydata, and fmt_zdata Mar 31, 2023
@oscargus
Copy link
Member

Just thought that I'd highlight #17286 as it is sort of related to this. At least the suggestion to rename this attribute and/or have setters/getters for it. Doesn't have to be a show stopper for this PR though.

@QuLogic QuLogic modified the milestones: v3.7.2, v3.7.3 Jul 5, 2023
@QuLogic QuLogic modified the milestones: v3.7.3, v3.8-doc Sep 6, 2023
@story645 story645 modified the milestones: v3.8-doc, v3.9-doc Jul 8, 2024
@rcomer
Copy link
Member

rcomer commented May 13, 2025

If I’m not mistaken, this is the answer to https://discourse.matplotlib.org/t/toolbar-parameters-in-show/25908/2

@github-actions github-actions bot added topic: mplot3d topic: axes Documentation: user guide files in galleries/users_explain or doc/users Documentation: API files in lib/ and doc/api labels May 16, 2025
@tacaswell tacaswell modified the milestones: v3.10-doc, v3.11.0 May 16, 2025
@tacaswell
Copy link
Member Author

This can't get pulled back to the doc branch (it touches library code).

@rcomer
Copy link
Member

rcomer commented May 16, 2025

Recently we have documented other attributes using class level type hints (and we did backport one of these): #29965 #28825

Would it make sense to do that here too?

@timhoffm
Copy link
Member

I'm a bit torn how to do this properly. The fundamental issue is that attributes are a dynamic concept and it's hard to attach meta information to them. Actually I don't like either approach: Class level type annotations are a bit awkward because we have otherwise pushed all typing to the stubs. OTOH I also don't like to create class attributes for documentation when we actually have instance attributes.

If I have to choose between those, I'd go for the type annotations, but YMMV.

@tacaswell
Copy link
Member Author

If we have two other instances of using the typing style and @timhoffm prefers it, go with that method!

@rcomer
Copy link
Member

rcomer commented May 17, 2025

Oh it seems it doesn't work for 3D. Is that because we have not typed the module more generally?

@timhoffm
Copy link
Member

Doc build failure due to

/home/circleci/project/doc/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.fmt_zdata.rst: WARNING: document isn't included in any toctree [toc.not_included]

But I don't really understand why this is the case.

@QuLogic
Copy link
Member

QuLogic commented Sep 12, 2025

@@ -57,6 +58,15 @@ class Axes3D(Axes):
Axes._shared_axes["z"] = cbook.Grouper()
Axes._shared_axes["view"] = cbook.Grouper()

fmt_zdata: Callable[[float], str] | None
Copy link
Member

Choose a reason for hiding this comment

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

Setting this to something seems to fix it, though again, not sure why it doesn't seem necessary on the others.

Suggested change
fmt_zdata: Callable[[float], str] | None
fmt_zdata: Callable[[float], str] | None = None

Copy link
Member

@QuLogic QuLogic Sep 12, 2025

Choose a reason for hiding this comment

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

I just had an idea... Neither of these exist as attributes on the class:

>>> from matplotlib.axes import Axes
>>> Axes.fmt_xdata
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    Axes.fmt_xdata
AttributeError: type object 'Axes' has no attribute 'fmt_xdata'. Did you mean: 'format_xdata'?

>>> from mpl_toolkits.mplot3d.axes3d import Axes3D
>>> Axes3D.fmt_zdata
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    Axes3D.fmt_zdata
AttributeError: type object 'Axes3D' has no attribute 'fmt_zdata'. Did you mean: 'format_zdata'?

and yet the former works.

But the difference between 2D and 3D Axes is the former has type stubs and the latter doesn't. Unfortunately, removing fmt_xdata/fmt_ydata from the _base.pyi type stub did not break the docs. So I still don't know why it doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: API files in lib/ and doc/api Documentation: user guide files in galleries/users_explain or doc/users Documentation topic: axes topic: mplot3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: need discoverable documentation for Axes.fmt_xdata
9 participants