cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
Mcc99
Level I

Adding connecting letters ABOVE data points of a line graph

I have letters from a connecting letters report, my means, and SEMs in columns of a new data table. I've created a line graph with points.  As suggested in previous discussion posts I've tried "Set shape column" but as you can see the letters are behind the line and so unreadable. I would like to add the letters as labels floating above the points (so they are legible). How can I adjust what position the letters appear at? Or add the letters a different way? Thanks!

 

Mcc99_0-1725034316017.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Adding connecting letters ABOVE data points of a line graph

Edit: I did this in JMP18. Not sure if it is exactly the same for JMP16 and I cannot test it out.

 

From connecting letters report, create a data table

jthi_0-1725036321496.png

In that table create new column by concatenating all letter columns (also rename it to something better)

jthi_1-1725036341485.png

Join/update that back to your original table (you might have to change Level column data type to match original)

jthi_2-1725036414198.png

Create new column which can be used to determine the Y-axis location

jthi_3-1725036456910.png

jthi_4-1725036473709.png

Edit the formula if necessary

jthi_5-1725036501654.png

Set the Letters column to be used as marker

jthi_7-1725036634212.png

Create your plot. Note how Y-axis has been set and how different variables have been disabled

jthi_8-1725036706421.png

Adjust the formula as necessary for TEMP (1.01 multiplier works in my data) and rename Y-axis after you are done

jthi_9-1725036762850.png

 

-Jarmo

View solution in original post

7 REPLIES 7
jthi
Super User

Re: Adding connecting letters ABOVE data points of a line graph

Which JMP version are you using?

 

I assume shape idea comes from this how does one add letters form a connecting letters report to a graph . Other option is here How to denote letters to mark significant differences in a boxplot? . With the second option you can add use the column as markers and then display plot graph with max summary statistic

Names Default To Here(1);

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

fit = dt << Oneway(Y(:height), X(:age), All Pairs(1), invisible);
letters_tb = ((Report(fit)[OutlineBox("Connecting Letters Report")]) << child) << child;

tb_letter_cols = Filter Each({col_name}, letters_tb << Get Names,
	Starts With(col_name, "~Letter Column ")
);

aa_letters = Associative Array();
For Each({level, idx}, letters_tb[1] << get,
	aa_letters[level] = "";
	For Each({letter_col, idx_col}, tb_letter_cols,
		aa_letters[level] ||= Try((letters_tb[1 + idx_col] << get)[idx], "");
	);
);
fit << close window;

dt << New Column("TukeyLetters", Character, Nominal, UseForMarker(1), << Set Each Value(
	aa_letters[char(:age)];
));

gb = dt << Graph Builder(
	Size(529, 451),
	Show Control Panel(0),
	Variables(X(:age), Y(:height)),
	Elements(
		Box Plot(X, Y, Legend(6), Box Style("Solid"), Fences(0)),
		Points(
			X,
			Y,
			Legend(7),
			Summary Statistic("Third Quartile"),
			Error Interval("None")
		)
	)
);

jthi_0-1725035285498.png

Then there is the option of using graphic script (or maybe marker draw expression) where you calculate where the text should be. This is the most flexible and complicated option.

 

Edit: There is one more option. You can create new column which determines the Y-axis for the point plot, then use that as extra column in Y-axis, disable it from everything except from the point plot. In this example height+2 is used as the extra column

jthi_1-1725035774312.png

And the calculation is just :height + 2. It could be easily made much smarter with Col Max(:height, :age) * 1.01 or something

-Jarmo
Mcc99
Level I

Re: Adding connecting letters ABOVE data points of a line graph

I'm using JMP Pro 16. When you say add the letters as markers, can I do that in the control panel or would it have to be through the script? 

jthi
Super User

Re: Adding connecting letters ABOVE data points of a line graph

I think you can do this without scripting but it will have quite a few steps.

-Jarmo
jthi
Super User

Re: Adding connecting letters ABOVE data points of a line graph

Edit: I did this in JMP18. Not sure if it is exactly the same for JMP16 and I cannot test it out.

 

From connecting letters report, create a data table

jthi_0-1725036321496.png

In that table create new column by concatenating all letter columns (also rename it to something better)

jthi_1-1725036341485.png

Join/update that back to your original table (you might have to change Level column data type to match original)

jthi_2-1725036414198.png

Create new column which can be used to determine the Y-axis location

jthi_3-1725036456910.png

jthi_4-1725036473709.png

Edit the formula if necessary

jthi_5-1725036501654.png

Set the Letters column to be used as marker

jthi_7-1725036634212.png

Create your plot. Note how Y-axis has been set and how different variables have been disabled

jthi_8-1725036706421.png

Adjust the formula as necessary for TEMP (1.01 multiplier works in my data) and rename Y-axis after you are done

jthi_9-1725036762850.png

 

-Jarmo
Mcc99
Level I

Re: Adding connecting letters ABOVE data points of a line graph

As I already have the letters in a column and don't need to generate them in a model, how would I add the column as a marker? 

Perhaps I can create a duplicate using something like this? 

Names Default To Here(1);
Weights = Open("jmpprj://contents/Weights.jmp");
Weights << New Column("test", Character, Nominal, UseForMarker(1), << DupCol ("Letters")
	);
Mcc99
Level I

Re: Adding connecting letters ABOVE data points of a line graph

Actually, your last reply showed me how to set the current column as the marker without scripting. So ignore my last reply. 

Mcc99
Level I

Re: Adding connecting letters ABOVE data points of a line graph

Thanks! This works very well, and is much quicker than adding them all by hand! 

I will second the many suggestions to add connecting letter labels to graph builder in future versions.