cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-243225%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E5%B0%87%E7%96%8A%E5%8A%A0%E8%AE%8A%E9%87%8F%E7%9A%84N%E6%94%BE%E5%88%B0%E5%9C%96%E5%BD%A2%E4%B8%8A%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-243225%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E7%9B%B8%E4%BF%A1%E6%82%A8%E9%9C%80%E8%A6%81%E5%81%9A%E7%9A%84%E6%98%AF%E5%90%91%E6%82%A8%E7%9A%84Graph%20Builder%E4%B8%AD%E6%B7%BB%E5%8A%A0%E4%B8%80%E5%80%8B%E8%87%AA%E5%AE%9A%E7%BE%A9%E7%9A%84JSL%E3%80%82%26nbsp%3B%20%E5%8F%AF%E4%BB%A5%E5%B0%8B%E5%9D%80%E6%AF%8F%E5%80%8B%E5%96%AE%E7%8D%A8%E7%9A%84%E5%9C%96%EF%BC%8C%E4%B8%A6%E4%B8%94%E5%8F%AF%E4%BB%A5%E7%B7%A8%E5%AF%AB%E8%85%B3%E6%9C%AC%E4%BB%A5%E5%B0%87%E9%81%A9%E7%95%B6%E7%9A%84N%E5%80%BC%E6%B7%BB%E5%8A%A0%E5%88%B0%E6%AF%8F%E5%80%8B%E5%9C%96%E4%B8%AD%E3%80%82%E4%B8%8B%E9%9D%A2%E6%98%AF%E4%B8%80%E5%80%8B%E5%9F%BA%E6%96%BC%E7%B0%A1%E5%96%AE%E5%9C%96%E5%BD%A2%E7%9A%84%E9%9D%9E%E5%B8%B8%E7%B0%A1%E5%96%AE%E7%9A%84%E7%A4%BA%E4%BE%8B%EF%BC%8C%E4%BD%86%E6%98%AF%E5%AE%83%E6%87%89%E8%A9%B2%E4%BD%BF%E6%82%A8%E4%BA%86%E8%A7%A3%E5%A6%82%E4%BD%95%E5%9F%B7%E8%A1%8C%E6%AD%A4%E6%93%8D%E4%BD%9C%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20593px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22text.PNG%22%20style%3D%22width%3A%20593px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F21359i8CF46930FA9742AF%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22text.PNG%22%20alt%3D%22text.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0Agb%20%3D%20dt%20%26lt%3B%26lt%3B%20Graph%20Builder(%0A%20Size(%20525%2C%20496%20)%2C%0A%20Show%20Control%20Panel(%200%20)%2C%0A%20Variables(%0A%20%20X(%20%3Aweight%20)%2C%0A%20%20Y(%20%3Aheight%20)%2C%0A%20%20Group%20X(%20%3Aage%20)%2C%0A%20%20Overlay(%20%3Asex%20)%0A%20)%2C%0A%20Elements(%20Line(%20X%2C%20Y%2C%20Legend(%208%20)%20)%20)%0A)%3B%0A%0A%2F%2F%20Get%20the%20counts%20for%20each%20of%20the%20ages%0ASummarize(%20dt%2C%20groupBy%20%3D%20By(%20%3AAge%20)%2C%20N%20%3D%20Count(%20%3AAge%20)%20)%3B%0A%0A%2F%2F%20Make%20sure%20stats%20are%20complete%20before%20moving%20on%0Await(0)%3B%0A%0A%2F%2F%20Find%20the%20upper%20right%20corner%20axis%20values%20so%20one%20can%20back%20off%20a%20bit%20and%20place%0A%2F%2F%20the%20values%20of%20N%20in%20an%20appropriate%20place%0A%2F%2F%20Place%20the%20values%20into%20a%20list%2C%20which%20is%20required%20for%20the%20graphic%20function%0A%2F%2F%20that%20is%20to%20be%20used%0AtheList%20%3D%20%7B%7D%3B%0AtheList%5B1%5D%20%3D%20(Report(%20gb%20)%5BAxisBox(%201%20)%5D%20%26lt%3B%26lt%3B%20get%20max)%20*%20.85%3B%0AtheList%5B2%5D%20%3D%20(Report(%20gb%20)%5BAxisBox(%202%20)%5D%20%26lt%3B%26lt%3B%20get%20max)%20*%20.95%3B%0A%0A%2F%2F%20Now%20Place%20the%20values%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20n%20)%2C%20i%2B%2B%2C%0A%20val%20%3D%20%22N%3D%22%20%7C%7C%20Char(%20n%5Bi%5D%20)%3Bshow(val)%3B%0A%20Report(%20gb%20)%5BFrameBox(%20i%20)%5D%20%26lt%3B%26lt%3B%0A%20add%20graphics%20script(%20Text(%20Center%20Justified%2C%20theList%2C%20val%20)%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-243229%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E5%B0%87%E7%96%8A%E5%8A%A0%E8%AE%8A%E9%87%8F%E7%9A%84N%E6%94%BE%E5%88%B0%E5%9C%96%E5%BD%A2%E4%B8%8A%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-243229%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%AC%9D%E8%AC%9D%EF%BC%81%E6%88%91%E4%BB%A5%E5%89%8D%E6%B2%92%E6%9C%89%E9%81%87%E5%88%B0%E9%81%8E%E5%B9%BE%E5%80%8BJSL%E5%91%BD%E4%BB%A4%EF%BC%8C%E6%88%91%E8%AA%8D%E7%82%BA%E9%80%99%E5%B0%8D%E6%88%91%E7%9A%84%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%A1%88%E8%87%B3%E9%97%9C%E9%87%8D%E8%A6%81%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-243208%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%A6%82%E4%BD%95%E5%B0%87N%E7%9A%84overlay%E8%AE%8A%E9%87%8F%E6%94%BE%E5%88%B0%E5%9C%96%E5%BD%A2%E4%B8%8A%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-243208%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E9%80%9A%E5%B8%B8%E7%94%9F%E6%88%90%E7%9A%84%E6%95%B8%E6%93%9A%E5%8F%AF%E8%A6%96%E5%8C%96%E4%B9%8B%E4%B8%80%E6%98%AF%E4%B8%80%E7%B5%84X%20%2F%20Y%E6%95%B8%E6%93%9A%EF%BC%8C%E9%80%99%E4%BA%9B%E6%95%B8%E6%93%9A%E6%8C%89%E4%BA%8C%E7%B6%AD%E9%A1%9E%E5%88%A5%E7%9A%84%E5%88%86%E9%A1%9E%E8%AE%8A%E9%87%8F%E5%88%86%E7%B5%84%EF%BC%8C%E4%BB%A5%E7%94%9F%E6%88%90%E5%9C%96%E7%9A%84%E6%AD%A3%E6%96%B9%E5%BD%A2%E9%99%A3%E5%88%97%EF%BC%9A%E8%AB%8B%E5%8F%83%E8%A6%8B%E7%A4%BA%E4%BE%8B%E3%80%82%E6%88%91%E9%80%B2%E4%B8%80%E6%AD%A5%3CEM%3E%E8%A6%86%E8%93%8B%3C%2FEM%3E%20X%20%2F%20Y%E6%95%B8%E6%93%9A%E7%94%B1%E8%A7%80%E5%AF%9FID%E7%B5%84%E6%88%90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B%E5%96%AE%E5%85%83%E6%A0%BC%E4%B8%AD%E6%89%8B%E5%8B%95%E6%B7%BB%E5%8A%A0%E6%A8%99%E7%B1%A4%E4%BE%86%E8%A7%A3%E6%B1%BA%E6%AD%A4%E5%95%8F%E9%A1%8C%EF%BC%8C%E4%BD%86%E9%80%99%E9%A1%AF%E7%84%B6%E5%BE%88%E9%BA%BB%E7%85%A9%E3%80%82%E6%88%91%E7%95%B6%E7%84%B6%E5%8F%AF%E4%BB%A5%E6%8F%90%E4%BE%9B%E5%85%B6%E4%BB%96%E5%8F%AF%E8%A6%96%E5%8C%96%E6%95%88%E6%9E%9C%EF%BC%8C%E4%BD%86%E6%98%AF%E6%88%91%E7%9A%84%E5%9C%98%E9%9A%8A%E6%88%90%E5%93%A1%E5%B7%B2%E8%A6%81%E6%B1%82%E9%80%B2%E8%A1%8C%E6%AD%A4%E7%89%B9%E5%AE%9A%E7%9A%84%E5%8F%AF%E8%A6%96%E5%8C%96%E6%95%88%E6%9E%9C%E3%80%82%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E6%98%AF%E5%90%A6%E5%BF%BD%E7%95%A5%E4%BA%86%E5%8F%AF%E4%BB%A5%E7%B0%A1%E5%96%AE%E5%9C%B0%E5%AF%A6%E7%8F%BE%E6%AD%A4%E7%9B%AE%E7%9A%84%E7%9A%84%E5%8A%9F%E8%83%BD%EF%BC%9F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Example.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F21360i1DABE8E2F4D645EB%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Example.jpg%22%20alt%3D%22Example.jpg%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Ian_Horne
Level I

How do I put N of the overlay variable onto a graph?

One of the data visualisations I am routinely producing is a set of X/Y data grouped by categorical variables in two dimensions to produce a square array of plots: see attached example. I further Overlay the X/Y data by an observation ID in order to connect all the data points from one observation with a line (placing another variable into the Color axis in order to keep the resulting plot readable).

 

I cannot guarantee that each of the cells in this array of plots has the same occupancy, for technical reasons. Therefore, the team members using the data that I am creating need to know exactly how many observations (unique values of the observation ID) are present in each cell, because otherwise the visualisation has the potential to mislead.

 

Because I am using the Overlay axis, if I use a Caption Box then I get one caption per value of the observation ID: what I have been asked to provide is one caption per cell, counting the number of unique values of observation ID there are in that cell.

 

Of course this can be worked around by manually adding labels into each cell, but this is distinctly laborious. Of course I can provide other visualisations, but my team members have requested this specific visualisation.

 

Am I overlooking a feature that will do this simply?

 

Example.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do I put N of the overlay variable onto a graph?

What I believe you will need to do, is to add a customized piece of JSL to your Graph Builder.  Each of the individual graphs can be addressed, and a script can be written to add the appropriate N value into each. Below is a very simple example based upon a simpler graph, but it should give you an idea on how to do this

text.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = dt << Graph Builder(
	Size( 525, 496 ),
	Show Control Panel( 0 ),
	Variables(
		X( :weight ),
		Y( :height ),
		Group X( :age ),
		Overlay( :sex )
	),
	Elements( Line( X, Y, Legend( 8 ) ) )
);

// Get the counts for each of the ages
Summarize( dt, groupBy = By( :Age ), N = Count( :Age ) );

// Make sure stats are complete before moving on
wait(0);

// Find the upper right corner axis values so one can back off a bit and place
// the values of N in an appropriate place
// Place the values into a list, which is required for the graphic function
// that is to be used
theList = {};
theList[1] = (Report( gb )[AxisBox( 1 )] << get max) * .85;
theList[2] = (Report( gb )[AxisBox( 2 )] << get max) * .95;

// Now Place the values
For( i = 1, i <= N Items( n ), i++,
	val = "N=" || Char( n[i] );show(val);
	Report( gb )[FrameBox( i )] <<
	add graphics script( Text( Center Justified, theList, val ) );
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How do I put N of the overlay variable onto a graph?

What I believe you will need to do, is to add a customized piece of JSL to your Graph Builder.  Each of the individual graphs can be addressed, and a script can be written to add the appropriate N value into each. Below is a very simple example based upon a simpler graph, but it should give you an idea on how to do this

text.PNG

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = dt << Graph Builder(
	Size( 525, 496 ),
	Show Control Panel( 0 ),
	Variables(
		X( :weight ),
		Y( :height ),
		Group X( :age ),
		Overlay( :sex )
	),
	Elements( Line( X, Y, Legend( 8 ) ) )
);

// Get the counts for each of the ages
Summarize( dt, groupBy = By( :Age ), N = Count( :Age ) );

// Make sure stats are complete before moving on
wait(0);

// Find the upper right corner axis values so one can back off a bit and place
// the values of N in an appropriate place
// Place the values into a list, which is required for the graphic function
// that is to be used
theList = {};
theList[1] = (Report( gb )[AxisBox( 1 )] << get max) * .85;
theList[2] = (Report( gb )[AxisBox( 2 )] << get max) * .95;

// Now Place the values
For( i = 1, i <= N Items( n ), i++,
	val = "N=" || Char( n[i] );show(val);
	Report( gb )[FrameBox( i )] <<
	add graphics script( Text( Center Justified, theList, val ) );
);
Jim
Ian_Horne
Level I

Re: How do I put N of the overlay variable onto a graph?

Thank you! There are a couple of JSL commands in there that I hadn't come across before, which I think will be key to my solution.