cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Linnear regression in scatter plot

jensc
17-Peridot

Linnear regression in scatter plot

Hello Community,

 

I was wondering if there is any way of "showing" linnear regression in a chart line?

I can only find the "HideLines" property on the line chart (scatter plot type) widget.

 

Here is an example using the g2plot library for further explanation:  https://g2plot.antv.antgroup.com/en/examples/scatter/scatter/#line

 

Regards,

Jens C

ACCEPTED SOLUTION

Accepted Solutions
Rocko
18-Opal
(To:jensc)

Jens, I have to roll back. Combo Chart isn't what I thought it was I was misled by the picture in the help, but you can't a line chart and a scatter plot into the same chart with it, sorry.

View solution in original post

8 REPLIES 8
Rocko
18-Opal
(To:jensc)

Hi Jens, is the goal to show the points and the regression line in one chart?

Then you would have to use the Combo Chart, if your version already has it. The Line chart widget can only show splines.

In the combo chart, you would have to provide the data for the regression line as well as the chart won't compute this on its own.

jensc
17-Peridot
(To:Rocko)

Hello @Rocko,

 

Yes, essentially I think that is what we would like.
Like this:

jensc_0-1709557847716.png

I did have a look in the Combo Chart documentation you linked, and the screenshot there doesn't exactly look like what we'd like. But perhaps we can work with it.
However, my 9.3.8 platform does not seem to include this widget... Is it something additional we need to install?

 

Regards,

Jens C.

 

Rocko
18-Opal
(To:jensc)

I'm afraid it's a feature of TWX 9.4+ only...

jensc
17-Peridot
(To:Rocko)

Hello @Rocko,

Ah okay, then I'll have to try it out on our 9.5 servers.
I'll get to testing it and get back if it is what I was looking for!

 

Regards,

Jens C.

Rocko
18-Opal
(To:jensc)

Jens, I have to roll back. Combo Chart isn't what I thought it was I was misled by the picture in the help, but you can't a line chart and a scatter plot into the same chart with it, sorry.

jensc
17-Peridot
(To:Rocko)

Hello @Rocko,

 

No worries.

Hopefully it will be added to the chart in the future.

 

Thanks,

Jens C.

jensc
17-Peridot
(To:Rocko)

Hello @Rocko,

 

I managed to get ahold of a 9.5 platform to try the Combo Chart.

However, I haven't really been able to create a chart similar to this one:

jensc_0-1709631668964.png

I do realize that there is no "Scatter" chart type for the Combo Chart.


I tried it using the following service just as a quick test: 

result = DataShapes["ScatterPlot"].CreateValues();

const data = [
  { regression: -2.2114, X: 1, Y: 4.181 },
  { regression: -1.7274, X: 2, Y: 4.665 },
  { regression: -1.0964, X: 3, Y: 5.296 },
  { regression: -1.0274, X: 4, Y: 5.365 },
  { regression: -0.9444, X: 5, Y: 5.448 },
  { regression: -0.6484, X: 6, Y: 5.744 },
  { regression: -0.7394, X: 7, Y: 5.653 },
  { regression: -0.5484, X: 8, Y: 5.844 },
  { regression: -0.0304, X: 9, Y: 6.362 },
  { regression: -0.0124, X: 10, Y: 6.38 },
  { regression: -0.0814, X: 11, Y: 6.311 },
  { regression: 0.0646, X: 12, Y: 6.457 },
  { regression: 0.0866, X: 13, Y: 6.479 },
  { regression: 0.1976, X: 14, Y: 6.59 },
  { regression: 0.3476, X: 15, Y: 6.74 },
  { regression: 0.1876, X: 16, Y: 6.58 },
  { regression: 0.4596, X: 17, Y: 6.852 },
  { regression: 0.1386, X: 18, Y: 6.531 },
  { regression: 0.2896, X: 19, Y: 6.682 },
  { regression: 0.6206, X: 20, Y: 7.013 },
  { regression: 0.4276, X: 21, Y: 6.82 },
  { regression: 0.2546, X: 22, Y: 6.647 },
  { regression: 0.5586, X: 23, Y: 6.951 },
  { regression: 0.7286, X: 24, Y: 7.121 },
  { regression: 0.7506, X: 25, Y: 7.143 },
  { regression: 0.5216, X: 26, Y: 6.914 },
  { regression: 0.5486, X: 27, Y: 6.941 },
  { regression: 0.8336, X: 28, Y: 7.226 },
  { regression: 0.5056, X: 29, Y: 6.898 },
  { regression: 0.9996, X: 30, Y: 7.392 },
  { regression: 0.5456, X: 31, Y: 6.938 },
];

data.forEach((element) => {
  result.AddRow(element);
});

 

Do you perhaps have an example I could check?

 

Regards,

Jens C.

Rocko
18-Opal
(To:jensc)

Nothing ready right now but I can check after my vacation.

Announcements


Top Tags