Creating an Overlay Plot based on a Radio Box Selection<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I'm creating a script that creates an Overlay Plot with one variable (price) on the x-axis and two variables on the y-axis. My script works fine, but now I want to create a dialog box in which a user could select which two variables to plot on the y-axis. There are set combinations, so I would like to use a Radio Box with the acceptable pairs listed. But unfortunately I can't tell the Overlay command which variables to use. The relevant portion of my code is:
| | Outline Box("Select Curves to Analyze",rb = Radio Box( {"Optimal Price Point", |
| | "Indifference Price Point", |
| | "Point of Marginal Cheapness", |
| | "Point of Marginal Expensiveness" |
| | } |
| ), | |
| | Outline Box("van Westendorf Graph", |
| | op = Data Table( "vw3" ) << Overlay Plot( |
| | X( :Price ), |
| | choose( rb << Get(), Y( :Expensive, :Bargain ), Y( :Too Expensive, :Cheap ) ), |
I though I'd use the choose function to return the relevant Y statement. But this doesn't work. Any suggestions?
Thanks,
Walt
Re: Creating an Overlay Plot based on a Radio Box SelectionThanks for this suggestion. It looks like it will do the trick, so I'll try it soon.
Thanks for all the help.
Walt
Re: Creating an Overlay Plot based on a Radio Box SelectionUnfortunately you will have to resort to building a string dynamically that contains the commands to create your overlay plot, and then executing that string. Here's an example that uses evalinsert:
dt = open("$sample_data\Car Physical Data.jmp");
choice_list = {"Turning Circle, Displacement", "Horsepower, Gas Tank Size"};
col_list = {":Turning Circle, :Displacement", ":Horsepower, :Gas Tank Size"};
option = 1;
nw = new window("Select Curves to Analyze", << modal,
rb = Radio Box(choice_list, option = rb << get;)
);
yaxis_label = choice_list[option];
yaxis_cols = col_list[option];
overlay_expr = evalinsert("\[Overlay Plot(
X( :Weight ),
Y( ^yaxis_cols^ ),
SendToReport(
Dispatch( {}, "", AxisBox, {Add Axis Label( "^yaxis_label^" )} ),
Dispatch( {}, "Y", TextEditBox, {Set Text( "^yaxis_label^" )} )
)
)]\");
eval(parse(overlay_expr));
It may seem complicated but I do this all the time when JMP doesn't want to recognize variables.
Re: Creating an Overlay Plot based on a Radio Box SelectionThanks, but how do I still tell Overlay Plot which pair of variables (as in Y( :Expensive, :Bargain ) ) to use?
Walt
Re: Creating an Overlay Plot based on a Radio Box SelectionWalt,
This should fix up the initial part of your code:
choice_list = {"Optimal Price Point",
"Indifference Price Point",
"Point of Marginal Cheapness",
"Point of Marginal Expensiveness"
};
nw = new window("Select Curves to Analyze", << modal,
rb = Radio Box(choice_list, option = rb << get;)
);
yaxis_label = choice_list[option];