Subscribe Bookmark RSS Feed

Variable Y Reference line based on X

vince_faller

Super User

Joined:

Mar 17, 2015

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

11899_pastedImage_0.png

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

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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))));

Report(gb)[Framebox(1)] << Add Graphics Script(

    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}

    );

);

11914_broken_reflines.png

2 REPLIES
Solution

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))));

Report(gb)[Framebox(1)] << Add Graphics Script(

    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}

    );

);

11914_broken_reflines.png

vince_faller

Super User

Joined:

Mar 17, 2015

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