Community Trekker

Joined:

Nov 2, 2016

## JSL - Adding a horizontal line (from a variable) to a plot

I am trying to add a horizonal line to a plot that I have made where the hieght of the line is a variable in the JSL (based on statitical calucations.  So for example:

```test_here = temp << Graph Builder(
Size( 534, 448),
Show Control Panel(0),
Variables( X( :Panels), Y( :Score), Color (:Code)),
Elements( Points(X,Y,Legend(24), Jitter(0)))
);
// Want to add the line Y = upper_bound <- Just a number calculated prior to this ```

I am sure this is another easy thing to do that I will add to my knowledge base soon.... Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Super User

Joined:

Jun 22, 2012

Solution

## Re: JSL - Adding a horizontal line (from a variable) to a plot

Here is a script that does what you want:

``````Names Default to Here( 1 );
test_here = Graph Builder(
Variables( X( :Column 6 ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, [0, -1]} ), Position( {0, -1} )}
)
)
);
upper_bound=70;
report(test_here)[axisbox(2)] << Add Ref Line( upper_bound, "solid", black, "", 2 );``````
Jim
2 REPLIES

Super User

Joined:

Jun 22, 2012

Solution

## Re: JSL - Adding a horizontal line (from a variable) to a plot

Here is a script that does what you want:

``````Names Default to Here( 1 );
test_here = Graph Builder(
Variables( X( :Column 6 ), Y( :height ), Color( :sex ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, [0, -1]} ), Position( {0, -1} )}
)
)
);
upper_bound=70;
report(test_here)[axisbox(2)] << Add Ref Line( upper_bound, "solid", black, "", 2 );``````
Jim

Community Trekker

Joined:

Nov 2, 2016

## Re: JSL - Adding a horizontal line (from a variable) to a plot

Thanks Jim this did the trick!