cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • We’re improving the Learn JMP page, and want your feedback! Take the survey
  • JMP monthly Newswire gives user tips and learning events. Subscribe
Choose Language Hide Translation Bar
lala
Level VIII

How to plot only for the selected range of data without extracting subsets?

For example, like this, I deliberately increased the data within the selected range:
Age ==14

dt=Open("$SAMPLE_DATA/Big Class.jmp");
dt<<Sort(By( age),Order(Ascending),replace table);
ca="NO";New Column(ca);Column(ca)<<Formula( if(row()==1|age!=lag(age,1),r=row();1,1+row()-r) );dt<<run formulas;Column(ca)<<deleteFormula;
ca="height1";New Column(ca);Column(ca)<<Formula( if(age==14,height*100,height) );dt<<run formulas;Column(ca)<<deleteFormula;
ca="weight1";New Column(ca);Column(ca)<<Formula( if(age==14,weight*100,weight) );dt<<run formulas;Column(ca)<<deleteFormula;
p1=dt<< Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables(
		X( :NO ),
		Y( :height1 ),
		Y( :weight1, Position( 1 ), Side( "Right" ) )
	),
	Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) )
);

Thanks Experts!

2025-05-16_16-23-08.png

9 REPLIES 9
lala
Level VIII

回复: How to plot only for the selected range of data without extracting subsets?

This is the effect of plotting after extracting the subsets

2025-05-16_16-34-38.png

Victor_G
Super User

Re: How to plot only for the selected range of data without extracting subsets?

Hi @lala,

 

You can use the local data filter (red triangle of Graph Builder options) to only plot a specific subset of your data and change it interactively.

Victor_G_0-1747386605698.png

 

JSL script : 

Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables(
		X( :NO ),
		Y( :height1 ),
		Y( :weight1, Position( 1 ), Side( "Right" ) )
	),
	Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
	Local Data Filter(
		Add Filter(
			columns( :age ),
			Where( :age == 14 ),
			Display( :age, N Items( 6 ) )
		)
	)
);

 

Hope this answer will help you,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
lala
Level VIII

Re: How to plot only for the selected range of data without extracting subsets?

Thanks Experts!
Can it achieve the use of different filters simultaneously when there are multiple graphics in the same drawing interface?
I tried but failed.

Thanks!

2025-05-16_17-42-03.png

Victor_G
Super User

Re: How to plot only for the selected range of data without extracting subsets?

If I understood correctly, no the local data filter apply to all graphs.

However, if you're interested in 2 age groups only, you could use the age variable as a "page" variable (for independant axis ranges/scales) or Group Y variable (for same axis ranges/scales) and only display the 2 age group thanks to local data filter :

Victor_G_0-1747389442865.png

 

JSL script : 


Graph Builder(
	Size( 630, 590 ),
	Show Control Panel( 0 ),
	Variables(
		X( :NO ),
		Y( :height1 ),
		Y( :weight1, Position( 1 ), Side( "Right" ) ),
		Page( :age )
	),
	Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
	Local Data Filter(
		Add Filter(
			columns( :age ),
			Where( :age == {12, 14} ),
			Display( :age, N Items( 6 ) )
		)
	)
);

 

Hope this helps,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
lala
Level VIII

Re: How to plot only for the selected range of data without extracting subsets?

Thanks!

Graph Builder(
	Size(435, 1042),
	Show Control Panel(0),
	Variables(X(:NO), Y(:height1), Y(:weight1, Position(1)), Group Y(:age)),
	Elements(Line(X, Y(1), Y(2), Legend(5)))
);

It seems that the effect of this method cannot be achieved by grouping "age" through the Y-axis.

Where( :age == {12,13, 14,15,16,17} ),

2025-05-16_19-09-57.png

 

lala
Level VIII

Re: How to plot only for the selected range of data without extracting subsets?

Consult an expert: What are the steps for manually creating a diagram in this way? I’ve tried several times but haven’t succeeded.
Please help again.Thanks!

Victor_G
Super User

Re: How to plot only for the selected range of data without extracting subsets?

Hi @lala,

 

I will start the step-by-step by beginning from your initial script and graph :

  1. From the red triangle next to "Graph Builder", click on "Local Data Filter"
  2. Double-click on "Age", and then CTRL+click on every age value you would like to display :
    Victor_G_0-1747401451034.png
  3. Select "Age" from the columns menu in Graph Builder and drag and drop in the "Page" zone :
    Victor_G_1-1747401535775.png

     

  4. Click on "Done " to obtain your final graph :
    Victor_G_2-1747401576123.png

     

You can read more about the graphic options and variable roles in Essential Graphing help and particularly the different Graph Zones roles and functions.

Hope you'll be able to reproduce the result with these step-by-step instructions,

Victor GUILLER

"It is not unusual for a well-designed experiment to analyze itself" (Box, Hunter and Hunter)
txnelson
Super User

Re: How to plot only for the selected range of data without extracting subsets?

One can easily generate a window that has 2 instances displayed.

txnelson_0-1747394039342.png

Names Default To Here( 1 );

dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << Sort( By( age ), Order( Ascending ), replace table );
ca = "NO";
New Column( ca );
Column( ca ) << Formula(
	If( Row() == 1 | age != Lag( age, 1 ),
		r = Row();
		1;
	,
		1 + Row() - r
	)
);
dt << run formulas;
Column( ca ) << deleteFormula;
ca = "height1";
New Column( ca );
Column( ca ) << Formula( If( age == 14, height * 100, height ) );
dt << run formulas;
Column( ca ) << deleteFormula;
ca = "weight1";
New Column( ca );
Column( ca ) << Formula( If( age == 14, weight * 100, weight ) );
dt << run formulas;
Column( ca ) << deleteFormula;
New Window( "graphs",
	V List Box(
		Graph Builder(
			Size( 534, 456 ),
			Show Control Panel( 0 ),
			Variables( X( :NO ), Y( :height1 ), Y( :weight1, Position( 1 ), Side( "Right" ) ) ),
			Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
			Local Data Filter( Add Filter( columns( :age ), Where( :age == 14 ), Display( :age, N Items( 6 ) ) ) )
		);
		Graph Builder(
			Size( 534, 456 ),
			Show Control Panel( 0 ),
			Variables( X( :NO ), Y( :height1 ), Y( :weight1, Position( 1 ), Side( "Right" ) ) ),
			Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
			Local Data Filter( Add Filter( columns( :age ), Where( :age == 12 ), Display( :age, N Items( 6 ) ) ) )
		);
	)
);
Jim
lala
Level VIII

Re: How to plot only for the selected range of data without extracting subsets?

Thank Jim!

I use this code to plot multiple stocks in the same table in this way.

The newly added K-line graph no longer has the red and green colors.


https://community.jmp.com/t5/Discussions/Presenting-stock-data-in-form-of-box-plot/td-p/322791/page/... 

2025-05-16_21-21-19.png

Recommended Articles