Displaying 6 results from an estimated 6 matches for "slope_1".
2020 Oct 23
2
How to shade area between lines in ggplot2
Thank you, but this split the area into two and distorts the shape of
the plot. (compared to
```
p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2],
linetype = "dashed", col = "royalblue") +
geom_abline(slope = slope_1, intercept = intercept_1 + 1/w[2],
linetype = "dashed", col = "royalblue")
```
Why there is a hole in the middle of t...
2020 Oct 26
0
How to shade area between lines in ggplot2
Hi
Put fill outside aes
p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2],
ymax = slope_1*x + intercept_1 + 1/w[2]), fill = "blue", alpha=0.1)
The "hole" is because you have two levels of data (red and blue). To get rid
of this you should put new data in ribbon call.
Something like
newdat <- trainset
newdat$z <- facto...
2020 Oct 23
5
How to shade area between lines in ggplot2
...el = "linear",
scale = FALSE)
#! plot
p = ggplot(data = trainset, aes(x=x, y=y, color=z)) +
geom_point() + scale_color_manual(values = c("red", "blue"))
# show decision boundaries
w = t(svm_model$coefs) %*% svm_model$SV # %*% = matrix multiplication
slope_1 = -w[1]/w[2]
intercept_1 = svm_model$rho / w[2]
p = p + geom_abline(slope = slope_1, intercept = intercept_1)
### here we go: can I use a shaded area between these two lines? ###
p = p + geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2],
linetype = "dashed"...
2020 Oct 23
2
How to shade area between lines in ggplot2
...ow support vectors
df_sv = trainset[svm_model$index, ]
p = p + geom_point(data = df_sv, aes(x=x, y=y),
color="purple", size=4, alpha=0.5)
# show hyperplane (decision boundaries are off set by 1/w[2])
w = t(svm_model$coefs) %*% svm_model$SV # %*% = matrix multiplication
slope_1 = -w[1]/w[2]
intercept_1 = svm_model$rho / w[2]
p = p + geom_abline(slope = slope_1, intercept = intercept_1, col =
"royalblue4")
p = p + geom_ribbon(aes(ymin=intercept_1 - 1/w[2],
ymax=intercept_1 + 1/w[2],
x=x, fill = "ban...
2020 Oct 23
0
How to shade area between lines in ggplot2
Hi
What about something like
p+geom_ribbon(aes(ymin = slope_1*x + intercept_1 - 1/w[2],
ymax = slope_1*x + intercept_1 + 1/w[2], fill = "grey70", alpha=0.1))
Cheers
Petr
> -----Original Message-----
> From: Luigi Marongiu <marongiu.luigi at gmail.com>
> Sent: Friday, October 23, 2020 11:11 AM
> To: PIKAL Petr <petr.pikal at pr...
2020 Oct 23
0
How to shade area between lines in ggplot2
...scale = FALSE)
>
> #! plot
> p = ggplot(data = trainset, aes(x=x, y=y, color=z)) +
> geom_point() + scale_color_manual(values = c("red", "blue")) # show
> decision boundaries w = t(svm_model$coefs) %*% svm_model$SV # %*% =
> matrix multiplication
> slope_1 = -w[1]/w[2]
> intercept_1 = svm_model$rho / w[2]
> p = p + geom_abline(slope = slope_1, intercept = intercept_1) ### here we
go:
> can I use a shaded area between these two lines? ### p = p +
> geom_abline(slope = slope_1, intercept = intercept_1 - 1/w[2],
> line...