# 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:** 5

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 14, 2020, 6:00pm UTC](https://discourse.julialang.org/t/adding-a-trendline-or-line-of-best-fit/44939/5 "2020-08-14T18:00:14Z")

</div>

There actually are a few posts on this if you search the forum. This one could be helpful: [Plot the confidence interval for a model fit](https://discourse.julialang.org/t/plot-the-confidence-interval-for-a-model-fit/37767)

In short you can plot the output of `predict` from the GLM package for a simple linear fit, or of course a logarithmic fit if you parametrize the model appropriately.

Moving averages are available from the `RollingFunctions` package.

I’m not normally one to present missing functionality as a “feature”, but this pre-packaged application of one-click trendlines has gotten people in trouble before, so there is something to be said for Julia requiring you to explicitly specify some form of model for your trendline:

> <https://twitter.com/NateSilver538/status/1257476755574718470>
>
> Josh Dawsey @jdawsey1

---

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