correct scatterpath + add linearfit
correct scatterpath so that color does not change (see https://github.com/JuliaPlots/Plots.jl/issues/1495). Add linearfit.
This commit is contained in:
parent
1ceb3a561f
commit
64f3d589b6
@ -161,20 +161,51 @@ end
|
|||||||
# path and scatter
|
# path and scatter
|
||||||
|
|
||||||
# create a path from steps
|
# create a path from steps
|
||||||
|
# see https://github.com/JuliaPlots/Plots.jl/issues/1495
|
||||||
@recipe function f(::Type{Val{:scatterpath}}, x, y, z)
|
@recipe function f(::Type{Val{:scatterpath}}, x, y, z)
|
||||||
x := x
|
x := x
|
||||||
y := y
|
y := y
|
||||||
seriestype := :scatter
|
seriestype := :scatter
|
||||||
|
@series begin
|
||||||
|
()
|
||||||
|
end
|
||||||
@series begin
|
@series begin
|
||||||
seriestype := :path
|
seriestype := :path
|
||||||
label := ""
|
label := ""
|
||||||
primary := false
|
primary := false
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
|
primary := false
|
||||||
()
|
()
|
||||||
end
|
end
|
||||||
@deps scatterpath path scatter
|
@deps scatterpath path scatter
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# regression line and scatter
|
||||||
|
|
||||||
|
# plots line corresponding to linear regression of y on a constant and x
|
||||||
|
@recipe function f(::Type{Val{:linearfit}}, x, y, z)
|
||||||
|
seriestype := :scatter
|
||||||
|
x := x
|
||||||
|
y := y
|
||||||
|
@series begin
|
||||||
|
()
|
||||||
|
end
|
||||||
|
X = hcat(ones(length(x)), x)
|
||||||
|
yhat = X * (X'X \ X'y)
|
||||||
|
@series begin
|
||||||
|
y := yhat
|
||||||
|
seriestype := :path
|
||||||
|
label := ""
|
||||||
|
primary := false
|
||||||
|
()
|
||||||
|
end
|
||||||
|
primary := false
|
||||||
|
()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@specialize
|
@specialize
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user