Skip to content

Deprecate parameter orientation of bar() and barh() - #17322

Closed
timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:bar-orientation
Closed

timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:bar-orientation

Conversation

@timhoffm

@timhoffm timhoffm commented May 4, 2020

Copy link
Copy Markdown
Member

PR Summary

While stated to be internal, there's a parameter 'orientation' to bar(), which is also documented. To make this very clear, this PR deprecates 'orientation' and uses a private '_orientation' parameter instead.

The aim is to finally remove 'orientation' also from the docs, because it's rather confusing than helpful to document a parameter and say it's not to be used.

@timhoffm timhoffm added the API: changes Changes to the public API, typically requiring deprecation. label May 4, 2020
@timhoffm timhoffm added this to the v3.3.0 milestone May 4, 2020
@anntzer

anntzer commented May 4, 2020

Copy link
Copy Markdown
Contributor

Can't this be done by just using _rename_parameter on bar()? (the parameter is already keyword-only)

@timhoffm

timhoffm commented May 4, 2020

Copy link
Copy Markdown
Member Author

It's more a deprecation than a rename. And _rename_parameter does not allow to set a message. It would recommend using _orientation, which we certainly do not want.

@timhoffm
timhoffm force-pushed the bar-orientation branch from 4c3cc9d to a40a9e9 Compare May 4, 2020 14:26
@anntzer

anntzer commented May 4, 2020

Copy link
Copy Markdown
Contributor

fair enough

@anntzer

anntzer commented May 4, 2020

Copy link
Copy Markdown
Contributor

I guess the question, though, remains as to why this should be private. For example we don't have hist() and histh(), just hist(..., orientation=...). It is true that the argument names are not optimal if using the "wrong" orientation, but I'm not sure that's a strong reason for the removal.
I guess I'm +/-0 on the removal :)

@timhoffm

timhoffm commented May 4, 2020 •

Copy link
Copy Markdown
Member Author

I guess the question, though, remains as to why this should be private.

My main motivation is that https://matplotlib.org/devdocs/api/_as_gen/matplotlib.axes.Axes.bar.html should not document orientation as "This is for internal use only." I don't want to have parameters, which we tell people to not use.

If we would design this from scatch, we could use direction-agnostic parameter names. But as is stands, the parameter of bar(..., orientation='horizontal') is rather confusing. Also, there's axh/vlines and axh/vspan. So there's other precedent of using two separate functions instead of orientation.

I think there should be one official way to draw horizontal bars. Other possibilites would be to deprecate barh() or to just remove the docs on orientation. But I think, hiding orientation is the least invasive change.

@anntzer

anntzer commented May 4, 2020 •

Copy link
Copy Markdown
Contributor

I think undocumenting it is good enough. (I'm not blocking the rename, just not so convinced by it.)


orientation = kwargs.pop('orientation', 'vertical')
if 'orientation' in kwargs:
orientation = kwargs['orientation']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if we are going to rename we should add a check that we don't get both.

@tacaswell

Copy link
Copy Markdown
Member

I am 👍 on un-documenting it, 50/50 on renaming it.

It is already not in the signature and keyword-only (as we are doing kwargs popping) so the upside of renaming is relatively small (it is already hidden from auto-completers) and we can get it out of the docs by the text describing it from the docstring to a in-line comment. On the other hand, we would make some users change there code to remove some thing that has been documented more-or-less forever (looks like the doc and the functionality came in via f0be66e but was only labeled as "for internal use" in e078f91 for 2.1).

@tacaswell

Copy link
Copy Markdown
Member

Can we push this to 3.4?

@timhoffm

Copy link
Copy Markdown
Member Author

I've extracted the un-documentation part to #17504. We can decide for 3.4 if we want to deprecate the parameter in favor of a private version.

@timhoffm timhoffm modified the milestones: v3.3.0, v3.4.0 May 24, 2020
@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 22, 2021
@jklymak
jklymak marked this pull request as draft May 8, 2021 20:41
@timhoffm timhoffm modified the milestones: v3.5.0, v3.6.0 Jul 11, 2021
@timhoffm timhoffm removed this from the v3.6.0 milestone Apr 30, 2022
@timhoffm

timhoffm commented May 1, 2022

Copy link
Copy Markdown
Member Author

I'm not following up on this. The undocumented state is good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: changes Changes to the public API, typically requiring deprecation. status: needs rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants