Skip to content
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

[Bug]: for non-rectilinear axes, axvline/axhline should behave as "draw a gridline at that x/y" #24996

Closed
anntzer opened this issue Jan 15, 2023 · 1 comment · Fixed by #26788

Comments

@anntzer
Copy link
Contributor

anntzer commented Jan 15, 2023

Bug summary

Currently, on polar axes, axvline correctly draws a radial line at a given angle, but axhline draws nothing. It would be nice if axhline provided an easy way to draw a circle at a given radius (= a line at constant r), something for which I don't think there's an easy API right now.
More generally, for arbitrary axes, it seems that axvline and axhline have "clear" generalizations as "draw a gridline at a given x or y value".
(And likewise for axvspan/axhspan.)

Code for reproduction

from pylab import *
polar(); axvline(-np.radians(22.5), color="C0"); axhline(.5, color="C1")

Actual outcome

test

Expected outcome

For polar axes, the solution is to explicitly set _interpolation_steps, i.e.
axhline(.5, color="C1").get_path()._interpolation_steps = 180. (Otherwise, what happens is that both ends of the axhline (at theta=0 and theta=2pi) end up being transformed to the same point and a degenerate, null line is drawn.)
test
Perhaps axvline/axhline should simply do that.

Additional information

One could ultimately consider drawing gridlines using axhline/axvline, if this is fixed.

Operating system

fedora

Matplotlib Version

3.7.0.dev1370+g651a87407a

Matplotlib Backend

mplcairo

Python version

3.10

Jupyter version

ENOSUCHLIB

Installation

git checkout

@javivallejo
Copy link

+1 to this issue.
Also, when using polar axes, yticks label cannot be modified with matplotlib.axes.Axes.tick_params (for example moving the label to be on top of the line instead of being on the right side).

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.

3 participants