# Adding a trendline or line of best fit

**URL:** <https://discourse.julialang.org/t/adding-a-trendline-or-line-of-best-fit/44939>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [August 14, 2020, 3:40pm UTC](https://discourse.julialang.org/t/adding-a-trendline-or-line-of-best-fit/44939 "2020-08-14T15:40:22Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [August 14, 2020, 11:52pm UTC](https://discourse.julialang.org/t/adding-a-trendline-or-line-of-best-fit/44939/7 "2020-08-14T23:52:46Z")

</div>

Note that AlgebraOfGraphics at the moment has only `linear` (linear regression) and `smooth` (LOESS regression, not sure what it corresponds to in Excel terminology), and lacks the other “trendline options”. On the flip side, the design is such that extra analyses can be added easily.

I suspect that instead of hardcoding a few (IMO arbitrary) choices, there should probably be a way for the user to pass a model of the data. Then AlgebraOfGraphics would do a least squared error fit and plot the result.

---

_[View the full topic](https://discourse.julialang.org/t/adding-a-trendline-or-line-of-best-fit/44939)._
