Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Adding a line to a chart

Hi

Please can someone tell me whether I would be able to add a diagonal line (y=x) to a chart without too much work. I have a scatter chart with calculated expressions for the x and y, and would like to see where these points lie relative to the line y=x?

Please let me know whether you need more information than this. Any help would be greatly appreciated.

Thanks.

Joao.

1 Solution

Accepted Solutions
danieloberbilli
Specialist II
Specialist II

Hi Joao,

this is the solution:

you have 3 expressions: 1st one is for x, 2nd is for y and 3rd is for the bubble size (optional - just type in "1"). Now copy your 1st expression so that it becomes an additional 4th expression. For this fourth expression (which is identical to your 1st) mark the checkbox "Linear" in the Trendlines-Box on the Expression-Page in Chart Properties (see screenshot below)...thats it!

 

Best Regards from Sault Ste Marie, Ontario

Daniel

View solution in original post

8 Replies
Not applicable
Author

hello

look under presentation -> Reference lines -> Add

danieloberbilli
Specialist II
Specialist II

Hi Joao,

this is the solution:

you have 3 expressions: 1st one is for x, 2nd is for y and 3rd is for the bubble size (optional - just type in "1"). Now copy your 1st expression so that it becomes an additional 4th expression. For this fourth expression (which is identical to your 1st) mark the checkbox "Linear" in the Trendlines-Box on the Expression-Page in Chart Properties (see screenshot below)...thats it!

 

Best Regards from Sault Ste Marie, Ontario

Daniel

whiteline
Master II
Master II

Hi, Daniel.

That's awesome.

I used a background image for that.

upd:

It seems that you can do nothing with trend line (style/color/width).

adamdavi3s
Master
Master

Hmmm I am not 100% sure I agree with this, should it not be the second expression which is made linear? But then I am no statestician so not sure if I am thinking (x=y) rather than (y=x)?!?!?!?!

For example, you can literally include expression 1 and expression 2, then apply the linear flag to the expression 2?

I am MORE than happy to be proven wrong in this case...!!!!

The example I have used to test this in the last week is in the link below, as we know the correlation figure:

http://easycalculation.com/statistics/learn-correlation.php

On the left is my example with the second expression set to linear, on the right is one where we include the first expression again as the fourth and apply a linear flag to it.

stats.jpg

Anonymous
Not applicable
Author

Hi

Your answer is correct for a different problem i.e. one of correlation. I was simply looking for a way to plot the line y=x (not y=mx+c) i.e. the line that crosses the exact same value on the x and y axis at every point. The one on thr right is therefore correct, and not the one on the left which would have been correct for a linear regression.

Thanks again.

Joao.

adamdavi3s
Master
Master

Thank you Joao!

My fault for completly misunderstanding the question!!!

My work certainly has been for correlation, and not simply a line

danieloberbilli
Specialist II
Specialist II

I think that you can at least edit the color - the linear line should  have one of the colors on the color-page in chart properties but depending on your dimensions/expressions...

Best Regards

Daniel

whiteline
Master II
Master II

Yes, but there is also a data point (circle) of that color.