# How do i plot a linear, best-fit line graph to calculate correlation?

**URL:** <https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055>\
**Category:** Kibana\
**Created:** [August 28, 2019, 7:38am UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055 "2019-08-28T07:38:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris2](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@chris2](https://discuss.elastic.co/u/chris2)\
**Post date:** [August 28, 2019, 7:38am UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055/1 "2019-08-28T07:38:36Z")

</div>

How do i plot a linear, best-fit line graph to calculate correlation between X and Y? can we do regression, etc on kibana? the graph function is not numerical right?

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [August 28, 2019, 2:57pm UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055/2 "2019-08-28T14:57:21Z")

</div>

I'm not aware of any built-in way to do this within the main Kibana functions, including Visualize, Timelion, TSVB. You might be able to do this with a Vega visualization, which gives you a lot more control over the post-processing and lets you run Elasticsearch DSL queries. However, I can't find any examples of doing a line of best fit using Vega. You might also be able to find a Kibana plugin that extends our built in capabilities with something custom.

---

<div class="post-metadata">

**Author:** ![chris2](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@chris2](https://discuss.elastic.co/u/chris2)\
**Post date:** [September 10, 2019, 11:24am UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055/3 "2019-09-10T11:24:01Z")

</div>

thanks! do you know where i can activate Vega?

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [September 10, 2019, 4:41pm UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055/4 "2019-09-10T16:41:51Z")

</div>

Vega is available in Kibana 6.2 onwards. This is a blog post that includes a lot more examples of how to get started: [https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana](https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 8, 2019, 4:41pm UTC](https://discuss.elastic.co/t/how-do-i-plot-a-linear-best-fit-line-graph-to-calculate-correlation/197055/5 "2019-10-08T16:41:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
