cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to get y-axis labels from multiple Y charts and change only specific labels?

In a multiple y plot, how can I get the plotted y-axis labels/tiles (e.g. say get AAA, BBB, CCC, DDD and FFF as a list) and change some specific ones (post plotting), say BBB and DDD to BBB1 and DDD1 respectively and replot (closing the old)?

 

Neo_0-1702311585084.png

 

 

When it's too good to be true, it's neither
3 REPLIES 3
jthi
Super User

Re: How to get y-axis labels from multiple Y charts and change only specific labels?

One option is to use << Get Legend Display and its items

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
lgnd = gb << Get Legend Display;
items = lgnd << Get Items;
For Each({item}, items,
	If(Contains({"12", "14"}, item << get label),
		item << Set label(Repeat(item << get label, 3))
	);
);
-Jarmo
Neo
Neo
Level VI

Re: How to get y-axis labels from multiple Y charts and change only specific labels?

@jthi Thanks. I am afraid, I do not follow. Perhaps I did not explain the case correctly. 

I want to capture the existing y-axis labels in a multiple y-axis plot, say in a list and then change specific ones to desired label names and replot. 

When it's too good to be true, it's neither
jthi
Super User

Re: How to get y-axis labels from multiple Y charts and change only specific labels?

ah.. I though you want to modify legend. Axis labels seem to be one of the annoying things (you can remove them and add new, but I'm not exactly sure how to get current label). So XPath to rescue like usually (might be a good idea to filter out graph title and possibly x-axis)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Size(528, 454),
	Show Control Panel(0),
	Variables(X(:height), Y(:height), Y(:weight)),
	Elements(Position(1, 1), Points(X, Y, Legend(3))),
	Elements(Position(1, 2), Points(X, Y, Legend(1)))
);

rep = Report(gb);

tebs = rep << XPath("//GraphBuilderTitleBox/TextEditBox");

For Each({teb}, tebs,
	cur_title = teb << get text;
	show(cur_title);
	If(cur_title == "weight",
		teb << Set Text(Repeat(cur_title, 2))
	);
);
-Jarmo