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

Skip to content

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

Closed
@anntzer

Description

@anntzer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions