Choose Language Hide Translation Bar

Super User

Joined:

Mar 17, 2015

## Variable Y Reference line based on X

Is there a way to have a reference line either disappear at a certain X or change at a specific X?  For instance

is it possible for green to go to blue at the purple line?

1 ACCEPTED SOLUTION

Accepted Solutions

Super User

Joined:

Jun 23, 2011

Solution

## Re: Variable Y Reference line based on X

It can be done with a graphics script. Right click on the FrameBox and select Customize…

Or do it with jsl. For example:

dt = Open("\$SAMPLE_DATA/Big Class.jmp");

Column("age") << set modeling type(continuous);

gb = dt << Graph Builder(Variables(X(:age), Y(:weight)), Elements(Points(X, Y, Legend(3))));

Description("reflines"),

bp = 13.5; //breakpoint

y1 = Mean(:weight[dt << get rows where(:age <= bp)]);

y2 = Mean(:weight[dt << get rows where(:age > bp)]);

Line(

Pen Size(2);

Pen Color("green");

{bp, Y Origin()};,

{bp, Y Range() + Y Origin()}

);

Line(

Pen Size(2);

Pen Color("blue");

{X Origin(), y1};,

{bp, y1}

);

Line(

Line Style(2);

Pen Size(2);

Pen Color("gray");

{bp, y1};,

{X Range() + X Origin(), y1}

);

Line(

Pen Size(2);

Pen Color("red");

{bp, y2};,

{X Range() + X Origin(), y2}

);

Line(

Line Style(2);

Pen Size(2);

Pen Color("gray");

{X Origin(), y2};,

{bp, y2}

);

);

2 REPLIES 2

Super User

Joined:

Jun 23, 2011

Solution

## Re: Variable Y Reference line based on X

It can be done with a graphics script. Right click on the FrameBox and select Customize…

Or do it with jsl. For example:

dt = Open("\$SAMPLE_DATA/Big Class.jmp");

Column("age") << set modeling type(continuous);

gb = dt << Graph Builder(Variables(X(:age), Y(:weight)), Elements(Points(X, Y, Legend(3))));

Description("reflines"),

bp = 13.5; //breakpoint

y1 = Mean(:weight[dt << get rows where(:age <= bp)]);

y2 = Mean(:weight[dt << get rows where(:age > bp)]);

Line(

Pen Size(2);

Pen Color("green");

{bp, Y Origin()};,

{bp, Y Range() + Y Origin()}

);

Line(

Pen Size(2);

Pen Color("blue");

{X Origin(), y1};,

{bp, y1}

);

Line(

Line Style(2);

Pen Size(2);

Pen Color("gray");

{bp, y1};,

{X Range() + X Origin(), y1}

);

Line(

Pen Size(2);

Pen Color("red");

{bp, y2};,

{X Range() + X Origin(), y2}

);

Line(

Line Style(2);

Pen Size(2);

Pen Color("gray");

{X Origin(), y2};,

{bp, y2}

);

);

Super User

Joined:

Mar 17, 2015

## Re: Variable Y Reference line based on X

Oh yeah.  I always forget that I can just draw.  Much appreciated.