Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
JulieSAppel
Level IV

Combining two graphs in one window

Hi,

I have created 2 graphs, each with a column switcher and added them in one single window through the below script:

BoxPlot = LBSelectSplit << Graph Builder(
	Size( 1199, 762 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables(
		X(
			:Visit Name,
			Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) )
		),
		Y( :Alanine Aminotransferase )
	),
	Elements( Box Plot( X, Y, Legend( 6 ) ) ),
	Column Switcher(
		:Alanine Aminotransferase,
		{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase,
		:Aspartate Aminotransferase, :Bilirubin, :C Reactive Protein, :Calcitonin,
		:Calcium, :Cholesterol, :Creatine Kinase, :Creatinine, :Eosinophils,
		:Erythrocytes, :Gamma Glutamyl Transferase,
		:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol,
		:Hematocrit, :Hemoglobin, :Hemoglobin A1C, :LDL Cholesterol, :Leukocytes,
		:Lipase, :Lymphocytes, :Monocytes, :Neutrophils, :Platelets, :Potassium,
		:Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
	)
);


MeanPlot = LBSelectSplit << Graph Builder(
	Size( 1181, 745 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Fit to Window( "Maintain Aspect Ratio" ),
	Variables(
		X(
			:Visit Name,
			Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) )
		),
		Y( :Alanine Aminotransferase )
	),
	Elements( Line( X, Y, Legend( 6 ), Error Bars( "Standard Error" ) ) ),
	Column Switcher(
		:Alanine Aminotransferase,
		{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase,
		:Aspartate Aminotransferase, :Bilirubin, :C Reactive Protein, :Calcitonin,
		:Calcium, :Cholesterol, :Creatine Kinase, :Creatinine, :Eosinophils,
		:Erythrocytes, :Gamma Glutamyl Transferase,
		:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol,
		:Hematocrit, :Hemoglobin, :Hemoglobin A1C, :LDL Cholesterol, :Leukocytes,
		:Lipase, :Lymphocytes, :Monocytes, :Neutrophils, :Platelets, :Potassium,
		:Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
	)
);

New Window("Select Lab Surveillance", CombinedGraphWindow = V List Box());
CombinedGraphWindow << append(Report(MeanPlot)) << append(Report(BoxPlot));


But the column switchers are not included in the new window. I know that one column switcher wont be able to "cover" both graphs so I want one for each graph just like when the graphs are in two separate windows. How can that be done?

 

Br Julie 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Combining two graphs in one window

It isn't wrong but it isn't necessary, as far as I can tell, to use the append capability of a display box here. New Window() can use the results from the assignment of Graph Builder to make the window on its own. This way makes for simpler, cleaner code, in my opinion.

 

New Window( "Select Lab Surveillance",
	MeanPlot = LBSelectSplit << Graph Builder(
		Size( 1181, 745 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Fit to Window( "Maintain Aspect Ratio" ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Line( X, Y, Legend( 6 ), Error Bars( "Standard Error" ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	),
	BoxPlot = LBSelectSplit << Graph Builder(
		Size( 1199, 762 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Box Plot( X, Y, Legend( 6 ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	)
);
Learn it once, use it forever!

View solution in original post

3 REPLIES 3
Highlighted
JulieSAppel
Level IV

Re: Combining two graphs in one window

Forgot the data table

Highlighted
txnelson
Super User

Re: Combining two graphs in one window

If you look at what does end up in the combined window, you will see that it is only a copy of the Graph Builder display, and that it has no ability to change etc.

What you need to do, is to append the actual code for the graph builders into the display window....something like:

New Window( "Select Lab Surveillance", CombinedGraphWindow = V List Box() );
CombinedGraphWindow << append(
	MeanPlot = LBSelectSplit << Graph Builder(
		Size( 1181, 745 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Fit to Window( "Maintain Aspect Ratio" ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Line( X, Y, Legend( 6 ), Error Bars( "Standard Error" ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	)
) << append(
	BoxPlot = LBSelectSplit << Graph Builder(
		Size( 1199, 762 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Box Plot( X, Y, Legend( 6 ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	)
);
Jim
Highlighted

Re: Combining two graphs in one window

It isn't wrong but it isn't necessary, as far as I can tell, to use the append capability of a display box here. New Window() can use the results from the assignment of Graph Builder to make the window on its own. This way makes for simpler, cleaner code, in my opinion.

 

New Window( "Select Lab Surveillance",
	MeanPlot = LBSelectSplit << Graph Builder(
		Size( 1181, 745 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Fit to Window( "Maintain Aspect Ratio" ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Line( X, Y, Legend( 6 ), Error Bars( "Standard Error" ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	),
	BoxPlot = LBSelectSplit << Graph Builder(
		Size( 1199, 762 ),
		Show Control Panel( 0 ),
		Show Legend( 0 ),
		Variables(
			X( :Visit Name, Order By( :Visit Number, Ascending, Order Statistic( "Mean" ) ) ),
			Y( :Alanine Aminotransferase )
		),
		Elements( Box Plot( X, Y, Legend( 6 ) ) ),
		Column Switcher(
			:Alanine Aminotransferase,
			{:Alanine Aminotransferase, :Albumin, :Alkaline Phosphatase, :Amylase, :Aspartate Aminotransferase,
			:Bilirubin, :C Reactive Protein, :Calcitonin, :Calcium, :Cholesterol, :Creatine Kinase,
			:Creatinine, :Eosinophils, :Erythrocytes, :Gamma Glutamyl Transferase,
			:Name( "Glomerular Filtration Rate, Estimated" ), :HDL Cholesterol, :Hematocrit, :Hemoglobin,
			:Hemoglobin A1C, :LDL Cholesterol, :Leukocytes, :Lipase, :Lymphocytes, :Monocytes, :Neutrophils,
			:Platelets, :Potassium, :Sodium, :Triglycerides, :Urea, :VLDL Cholesterol}
		)
	)
);
Learn it once, use it forever!

View solution in original post

Article Labels

    There are no labels assigned to this post.