cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
patriciafm811
Level II

Add reference line to Y-group axis

Hello, 

I am using graph builder (JMP 17) and have almost what I need. But I need to add a reference line. 

 

This first image ('example') is what I currently have (I need all 3 viruses in 1 graph with lines and dots for the rates for both years). 

patriciafm811_0-1706640947824.png

BUT, I need to add a reference line for each virus so that it looks like 'example with ref line' (below).

patriciafm811_1-1706641063371.png

 

I don't know if it is possible. But essentially, I am trying to get a reference line to show up for each one my y-groups. I can use JSL if someone has something that will work using scripts. 

14 REPLIES 14
jthi
Super User

Re: Add reference line to Y-group axis

Not sure anymore what lines we are plotting here

Names Default To Here(1); 

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

gb = dt << Graph Builder(
	Variables(X(:weight), Y(:height), Group Y(:sex)),
	Elements(Points(X, Y, Legend(11)))
);

fbs = Report(gb) << XPath("//FrameBox");

lines = {60, 65};

For Each({fb, idx}, fbs,
	fb << Add Line Annotation(Line({478, (192 / (70.76 - 50)) * (70.76 - lines[idx])}, {478 + 42, (192 / (70.76 - 50)) * (70.76 - lines[idx])}), Color("Blue"));
);

jthi_0-1706721139746.png

 

-Jarmo
patriciafm811
Level II

Re: Add reference line to Y-group axis

Attached is the data file. I only need 2022 and 2023 in the final graph. 

This is what it should like (but instead of gray lines, they are green, and actually in there instead of just drawn in manually at a guess). The line for HIV is 12.7, HCV is 1.6, and HBV is 0.6.

patriciafm811_0-1706725823003.png

 

jthi
Super User

Re: Add reference line to Y-group axis

I still think it would be better to create new column into your data table with the values and use separate line chart, but here is graphic script version

Names Default To Here(1);

dt = Open("$DOWNLOADS/Stacked Combined CSV files.jmp");

gb = dt << Run Script("PPTA Overall Infection Rates All");

fbs = Report(gb) << XPath("//FrameBox");
lines = {12.7, 1.6, 0.6}; // These must be in correct order (using associative array could be better idea

For Each({fb, idx}, fbs,
	Eval(EvalExpr(
		fb << Add Graphics Script(
			Pen Color("Green");
			H Line(Expr(lines[idx]));
		);
	));
);

jthi_0-1706728177565.png

 

-Jarmo
patriciafm811
Level II

Re: Add reference line to Y-group axis

I will try this. I don't want to add columns to the existing file. 

Re: Add reference line to Y-group axis

...and you could do a slightly different version of that by using the "Page" function. That allows you to specify individual Ref lines per Virus. However the visual is not so nice, since it creates 3 different graphs basically:

 

Florian_Vogt_0-1706646632251.png

 

Best

Florian