问题

R's abline draws a straight line parameterised by `y = ax+b`

on the x-y 2D coordinate plan.

What's Julia's equivalent of that in Plots.jl?

答案

There is `Plots.abline!`

which draws a straight line in the form of `ax+b`

respecting axis limits of the plot. So it will not actually go to infinity but does not require you to know what the axis limits are beforehand.

```
plot(x->((x^2+3x+2)/(x-2)), 6, 30, xlim=(6,30), size=(300,300))
# draw oblique asymptote to the above function (y=x+5)
Plots.abline!(1, 5, line=:dash)
```

You can also plot a *straight line* using only two points that are on the line. This should also respect the axis limits.

```
plot!([x1, x2], [y1, y2], seriestype = :straightline, kwargs...)
```

What's Julia's Plots.jl's equivalent of R's `abline`?

相关问答

- Integrating Fortran code in Julia
- How can I have a cell array in Julia?
- How to resolve PCRE compilation error: range out of order in Julia?
- Column name as a variable in DataFramesMeta macros
- How to merge two 4-dims arrays by the 3th dim
- Select subset of rows of dataframe using multiple conditions
- Array of calendar month names or abbreviations
- What's Julia's Plots.jl's equivalent of R's `abline`?
- The command to add to path in Julia language
- Symbolic Math in Julia?