Skip to content

abline() - for drawing arbitrary lines on a plot, given specifications. #5253

Closed
@naught101

Description

@naught101

It would be really nice to have some function that could draw arbitrarily angled straight lines on a graph, along the lines of ggplot's abline

for example, these might be ways to draw infinite lines:

pl.abline(intercept=0, slope=1)  # 1:1 line from the origin

pl. abline(a=[0, 0], b=[1, 1])  # same line as above, using 2 points

pl.abline(a=[0, 0], angle=45)  # same line again, using 1 point and an angle

pl.abline(a=[0, 0], gradient=1)  # same line again, using 1 point and the gradient

These are all infinite lines (they extend to the bounds of the graph, regardless of where their specified points lie).

There are a few questions on stack overflow indicating how popular this might be, eg:
http://stackoverflow.com/questions/22104256/does-matplotlib-have-a-function-for-drawing-diagonal-lines-in-axis-coordinates

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions