You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement the equivalent of abline (plot line using slope/intercept only) to add line to graph #3166
Currently there seems to be no way to add a line to an existing graph (e.g. as a new trace) based on slope and intercept and without the necessity to find out the actual ranges of x and y axes of the figure.
All examples I have seen so far are based on using existing x values of dots in a scatter plot, calculating the corresponding y values for the line and adding those line segments in a new scatter plot trace.
But this has two huge disadvantages:
the y values have to get calculated for those x values (which may be a lot) or x values need to get selected
if a lot of segmets are calculated, the graph complexity increases a lot as well
But plotting a line based on just slope and intercept is probably the second most easy thing to do, so there should be a way to add a line that way.
The basic signature of the corresponding method or class could be similar to the corresponding R function: ABline(a=intercept, b=slope, h=yforhorizontallines, v=xforverticallines)
This would be really useful - this often comes up when the options for controlling the trendline through px.scatter don't enable retrieving the a + bx line we're trying to show.
Reacted by Johann Petrak, Prajval-1608 and Jared Yu
I also second here. This functionality is just handy in many several cases. And ultimately, this is a simple vector, which should be easy to draw and scale. The px.scatter solutions over StackOverflow are basic "manual" rasterization. In other words, we are using raster images where vector images are perfectly acceptable and fine (and probably much faster and less data-intensive).
(and probably much faster and less data-intensive)
Extremely important aspect for java-script based renderers, where all the data points of that line have to get stored in the browser, instead of a single geometric object. In a large graph with high resolution the workaround is painfully inefficient.
The hvplot/Bokeh library has proper graph elements like line, circle etc for such things.
I can add a sketch func that indirectly avoids "examples I have seen so far are based on using existing x values of dots in a scatter plot" - but it's certainly not suitable for production in its current form.
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
This is an unsolved issue and in comparison to other plotting libraries (e.g. matplotlib) a serious lack of functionality: please read the previous comments why.
In reality it is not just about lines but other kinds of curves or graphics primitives one may want to add to plot.
Reacted by Janosh Riebesell, harrylojames, Felix Brechtmann and Chemscribbler
thanks @johann-petrak and @janosh - I'll reopen and add to our backlog but realistically it will be months before we can get to it. If either of you would like to submit a PR, I'll prioritize reveiw.
Activity
johnc1231 commentedon Dec 8, 2021
Seconded. I am looking for way to draw an infinite line, and there doesn't seem to be any possible way to do so currently.
brianstthomas commentedon Sep 9, 2022
This would be really useful - this often comes up when the options for controlling the trendline through px.scatter don't enable retrieving the a + bx line we're trying to show.
ceandrade commentedon Mar 10, 2023
I also second here. This functionality is just handy in many several cases. And ultimately, this is a simple vector, which should be easy to draw and scale. The px.scatter solutions over StackOverflow are basic "manual" rasterization. In other words, we are using raster images where vector images are perfectly acceptable and fine (and probably much faster and less data-intensive).
johann-petrak commentedon Mar 10, 2023
Extremely important aspect for java-script based renderers, where all the data points of that line have to get stored in the browser, instead of a single geometric object. In a large graph with high resolution the workaround is painfully inefficient.
The hvplot/Bokeh library has proper graph elements like line, circle etc for such things.
j-at-ch commentedon Jun 7, 2024
+1 on this issue.
I can add a sketch func that indirectly avoids "examples I have seen so far are based on using existing x values of dots in a scatter plot" - but it's certainly not suitable for production in its current form.
I'd also much appreciate a library solution, Plotly team, if you read this :)
gvwilson commentedon Jul 11, 2024
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
johann-petrak commentedon Jul 11, 2024
This is an unsolved issue and in comparison to other plotting libraries (e.g. matplotlib) a serious lack of functionality: please read the previous comments why.
In reality it is not just about lines but other kinds of curves or graphics primitives one may want to add to plot.
janosh commentedon Jul 11, 2024
strongly agree, this is high prio and should not be closed
gvwilson commentedon Jul 11, 2024
thanks @johann-petrak and @janosh - I'll reopen and add to our backlog but realistically it will be months before we can get to it. If either of you would like to submit a PR, I'll prioritize reveiw.
Add add_abline for drawing a line from slope and intercept