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

Skip to content

[Doc]: text alignment defaults #27345

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

Closed
jsalsman opened this issue Nov 19, 2023 · 1 comment · Fixed by #27346
Closed

[Doc]: text alignment defaults #27345

jsalsman opened this issue Nov 19, 2023 · 1 comment · Fixed by #27346
Milestone

Comments

@jsalsman
Copy link
Contributor

jsalsman commented Nov 19, 2023

Documentation Link

https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.text.html

Problem

  • It would be fantastic if the default text horizontalalignment (left) and verticalalignment (baseline) were documented in matplotlib.pyplot.text.html please.
  • For reference, the defaults are not set in rcParams, but in the Text class at lib/matplotlib/text.py here:
def __init__(self,
             ...
             verticalalignment='baseline',
             horizontalalignment='left',
             ...
             ):

There are a few other similar excerpts in text.py for resetting defaults, etc.

Sorry I'm not skilled enough to do a PR myself. [Got it, I believe: #27346] Thank you for your kind consideration of this request.

Suggested improvement

  • alongside "horizontalalignment or ha"
    • change: {'left', 'center', 'right'}
    • to: {'left', 'center', 'right'}, default: left
  • alongside "verticalalignment or va"
    • change: {'bottom', 'baseline', 'center', 'center_baseline', 'top'}
    • to: {'bottom', 'baseline', 'center', 'center_baseline', 'top'}, default: baseline
@jsalsman
Copy link
Contributor Author

jsalsman commented Nov 19, 2023

Also, while unsuccessfully trying to figure out Sphinx to make a PR, I found this docstring mistake at https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/text.py#L126

        The text is aligned relative to the anchor point (*x*, *y*) according
        to ``horizontalalignment`` (default: 'left') and ``verticalalignment``
        (default: 'bottom'). See also

Where "bottom" should be "baseline".

If someone can tell me where the source for matplotlib.pyplot.text.html comes from, I will gladly do a PR for this and the above. EDIT: Submitted PR #27346 which also adds the defaults to https://matplotlib.org/devdocs/gallery/text_labels_and_annotations/text_alignment.html

oscargus pushed a commit that referenced this issue Dec 13, 2023
* Show and correct default alignment parameters in text.py

For issue [Doc]: text alignment defaults #27345

* Update text.py: line too long

* Show defaults in text_alignment.py

* Make setter method defaults match new docstrings in text.py

See #27346 (review)

* IDL text alignment set_ method defaults for text.pyi

* revert interface defaults in text.pyi

* revert defaults in alignment set_ methods text.py

did change the order of allowed arguments for set_verticalalignment per @StefRe

* Document  text alignment defaults in _axes.py

Because this is where the header at https://matplotlib.org/devdocs/api/_as_gen/matplotlib.pyplot.text.html comes from.

* rm trailing whitespace in _axes.py
@oscargus oscargus added this to the v3.8.3 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants