cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
JulieSAppel
Level IV

Fill color for multiple reference lines

Hi,

I have added multiple reference lines to the axis axis of a graph.

I´m doing this by looping through a reference line table (DarkLight) based on the main table.

Oxygen consumption = SableData << Graph Builder(
Size( 1322, 944 ),
Variables(
X( :Name( "Time since first dose-[hours]" ) ),
Y( :Name( "VO2-[ml/min]" ) ),
Overlay( :Treatment )
),
Elements( Points( X, Y, Legend( 4 ) ) )
);

For( i = 1, i <= N Rows( DarkLight ), i++, Report( Oxygen consumption )[AxisBox( 1 )] << add ref line( DarkLight:name("Time since first dose-[hours]")[i], DarkLight:Phase[i] ) );

JulieSAppel_0-1592397539450.png

 

Is there anyway I can add fill color in between some of the lines (based on column data in the DarkLight table) thereby indicating when it is daytime or nighttime?

Br Julie

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Fill color for multiple reference lines

Your example does not add two references lines. It adds a colored region in the range when you supply a list with two values.

 

You might have to modify the reference data table that you construct. This example should illustrate the approach;

 

Names Default to Here( 1 );

// data table with reference line specifications
ref dt = New Table( "Reference Lines",
	Add Rows( 5 ),
	New Column( "Segment",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4, 5] )
	),
	New Column( "Low",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [50, 55, 60, 65, 70] )
	),
	New Column( "High",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [55, 60, 65, 70, 75] )
	),
	New Column( "Color",
		Character,
		"Nominal",
		Set Values( {"Red", "Yellow", "Green", "Yellow", "Red"} )
	)
);

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

biv = data << Bivariate( Y( :weight ), X( :height ) );

x axis = Report( biv )[AxisBox(2)];

For Each Row( ref dt,
	// draw colored regon
	Eval( Eval Expr( x axis << Add Ref Line( { Expr( :Low ), Expr( :High ) }, "Solid", Expr( :Color ), , , 0.25 ) ) );
	// draw border lines
	Eval( Eval Expr( x axis << Add Ref Line( Expr( :Low ), "Solid", "Black" ) ) );
	Eval( Eval Expr( x axis << Add Ref Line( Expr( :High ), "Solid", "Black" ) ) );
); 

View solution in original post

7 REPLIES 7

Re: Fill color for multiple reference lines

Reference lines can use a range of values, along with a transparency to blend the color with the background.  This example using Big Class sample data produces the image below:

 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << Bivariate(
	Y( :weight ),
	X( :height ),
	Fit Line( {Line Color( {212, 73, 88} )} )
);
(biv<<Report)[AxisBox(2)] << Add Ref Line( {55, 65}, "Solid", "Black", "label", 1, 0.25 );

rangeref.png

 

 

Re: Fill color for multiple reference lines

I knew how this message worked but when I went to the Scripting Index to get a reference for Julie, I discovered it is incomplete:

 

Capture.JPG

JulieSAppel
Level IV

Re: Fill color for multiple reference lines

Thanks for the replies but this would require that I manually add the reference lines. My data set is constantly changing so I am looking for at solution where I can use the reference table that I have scripted to be created every time I run my data through this and automatically add the reference lines to the graph.

 

But I can´t seem to come up with a solution that adds different properties to the different ref lines when they are added like this.  

Re: Fill color for multiple reference lines

You iterate over the rows in your reference table and add a reference line (range) each time. Our answers did not involve the UI, only scripts, so it is not clear why you are confused or unable to proceed.

JulieSAppel
Level IV

Re: Fill color for multiple reference lines

My problem concerns this part in one of the suggestions:

Add Ref Line( {55, 65}, "Solid", "Black", "label", 1, 0.25 )

This would add two ref lines at 55 and 65 and they have the same properties (solid, black etc).

 

If I need to add e.g. a 100 ref lines which change depending on the specific data set being run through the script and they need to be shown with different properties (e.g. one is dotted and red, the next one is solid and blue etc). 

 

How would you do that without having to manually add each value in the script? 

Re: Fill color for multiple reference lines

Your example does not add two references lines. It adds a colored region in the range when you supply a list with two values.

 

You might have to modify the reference data table that you construct. This example should illustrate the approach;

 

Names Default to Here( 1 );

// data table with reference line specifications
ref dt = New Table( "Reference Lines",
	Add Rows( 5 ),
	New Column( "Segment",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4, 5] )
	),
	New Column( "Low",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [50, 55, 60, 65, 70] )
	),
	New Column( "High",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [55, 60, 65, 70, 75] )
	),
	New Column( "Color",
		Character,
		"Nominal",
		Set Values( {"Red", "Yellow", "Green", "Yellow", "Red"} )
	)
);

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

biv = data << Bivariate( Y( :weight ), X( :height ) );

x axis = Report( biv )[AxisBox(2)];

For Each Row( ref dt,
	// draw colored regon
	Eval( Eval Expr( x axis << Add Ref Line( { Expr( :Low ), Expr( :High ) }, "Solid", Expr( :Color ), , , 0.25 ) ) );
	// draw border lines
	Eval( Eval Expr( x axis << Add Ref Line( Expr( :Low ), "Solid", "Black" ) ) );
	Eval( Eval Expr( x axis << Add Ref Line( Expr( :High ), "Solid", "Black" ) ) );
); 
JulieSAppel
Level IV

Re: Fill color for multiple reference lines

Ok that makes sense. I missed the list part. Thanks for the response - I will change the reference table as you suggest.