Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Re: Overlay linear fit of subset of data on top of contour plot of all data

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 9, 2019 4:06 AM
(275 views)

Dear All,

I am trying to produce a plot and would appreciate any help I can get. I feel like what I want to do it pretty simple, but I cannot figure out how to do it through the JMP interface or through scripting.

I have a data table with 100 rows, and each row has an X, Y pair that follow a linear relationship. I also have a third categorical variable labeled "Option". I can easily produce a contour plot with X and Y axes, and color the contour via the Option column. I can also easily select only the rows where :Option == "Option 3" and produce a fit to this subset of data.

However, what I cannot seem to do is to produce a contour plot of all the data, with a linear fit of only a subset of data (Option 3) overlayed on the same figure using the same axes.

If someone could help me achieve this I would be really grateful.

I have attached the data table as well as a mock-up image of what I wish to achieve.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Hi @pjkiley,

It's very difficult to get Graph Builder to plot separate subsets like that, and @dale_lehman's suggestion of Copy Frame Contents is a great way to overlay graph elements from separate plots. But, as you noticed when scripting this gets complicated since those pasted frame contents do not come along.

Another option would be to plot all the elements, but then hide (or specifically, make completely transparent) the levels you don't wish to see. That's effectively the same as plotting only the level you do wish to see. Here's a quick gif of how to do that using what I think is the same structure as your data:

and here is the script to reproduce:

```
Open("$SAMPLE_DATA\Big Class.jmp");
Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :sex ) ),
Elements( Contour( X, Y, Overlay( 0 ), Legend( 16 ) ), Line Of Fit( X, Y, Legend( 17 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 17, Properties( 1, {Transparency( 0 )}, Item ID( "M", 1 ) ) )}
)
)
);
```

I didn't show it, but you can also hide the unused elements from your legend by double-clicking, then unchecking the ones you wish to hide:

I hope this helps get you closer!

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Overlay linear fit of subset of data on top of contour plot of all data

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Overlay linear fit of subset of data on top of contour plot of all data

Thanks very much for the suggestion. This does indeed work.

However, I should have mentioned in my previous email that I would like to save this as a script to the data table because I will need to generate this plot several hundred times. When I save the script after copying the frame contents, the frame contents part does not get saved. Is there another way to do it?

Thanks again,

P

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Hi @pjkiley,

It's very difficult to get Graph Builder to plot separate subsets like that, and @dale_lehman's suggestion of Copy Frame Contents is a great way to overlay graph elements from separate plots. But, as you noticed when scripting this gets complicated since those pasted frame contents do not come along.

Another option would be to plot all the elements, but then hide (or specifically, make completely transparent) the levels you don't wish to see. That's effectively the same as plotting only the level you do wish to see. Here's a quick gif of how to do that using what I think is the same structure as your data:

and here is the script to reproduce:

```
Open("$SAMPLE_DATA\Big Class.jmp");
Graph Builder(
Variables( X( :height ), Y( :weight ), Overlay( :sex ), Color( :sex ) ),
Elements( Contour( X, Y, Overlay( 0 ), Legend( 16 ) ), Line Of Fit( X, Y, Legend( 17 ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model( 17, Properties( 1, {Transparency( 0 )}, Item ID( "M", 1 ) ) )}
)
)
);
```

I didn't show it, but you can also hide the unused elements from your legend by double-clicking, then unchecking the ones you wish to hide:

I hope this helps get you closer!