cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ellielee115
Level I

Can I use a list to populate the X and Y axis in graph builder when scripting?

I have a list of X and Y values that the user selects. I want those list values to populate the x and y axis in graph builder. Is this possible.? I continually get an error that the column names cannot be found?

For example:

x_values = {"x1", "x2", "x3"}

y_values = {'y1", "y2", "y3"}

I want the x axis to be the x_values and the y axis to be the y_values. This changes by how the user selects though so the values cannot be hardcoded.

6 REPLIES 6
pmroz
Super User

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

Try something like this:

dt = open("$sample_data\Big Class.jmp");

column(dt, "height") << set name("x1");

column(dt, "weight") << set name("y3");

x_values = {"x1", "x2", "x3"};

y_values = {"y1", "y2", "y3"};

Graph Builder(

    Show Control Panel( 0 ),

    Variables( X( :column(dt, x_values[1]) ), Y( column(dt, y_values[3]) ) ),

    Elements( Points( X, Y, Legend( 1 ), Jitter( 1 ) ) )

);

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

If you need to put all of the selections in at once (for multiple variables on X and Y axes simultaneously), and you don't know the size of the lists in advance, you could do something involving expressions, which is a somewhat advanced, but flexible, technique. Here's an example. Note that gbExpr is the simply whatever code you want for graph builder, except for the Variables() part, which we will build dynamically:

dt = Open( "$Sample_Data/Car Physical Data.jmp" );

x_values = {"Country", "Type", "Weight"};

y_values = {"Turning Circle", "Displacement", "Horsepower"};

gbExpr = Expr( Graph Builder() );

varExpr = Expr( Variables() );

For( i = 1, i <= N Items( x_values ), i++,

    Insert Into( varExpr, Parse( "X( :" || x_values || ")" ) )

);

For( i = 1, i <= N Items( y_values ), i++,

    Insert Into( varExpr, Parse( "Y( :" || y_values || ")" ) )

);

Insert into( gbExpr, Name Expr( varExpr ) );

gbExpr;

Cheers,

Brady

ellielee115
Level I

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

Thanks for your help!

Unfortunately when I try to run this I get the following error:

Unexpected ")".

Trying to parse operand for "-" operator.

Line 1 Column 12: Y( : A-3 - ►)

My list of Y variables looks like this y_variables = {" A-3-", " A-4-"}

I also am not not trying to put multiple y variables on the same axis. I want each of the y variables to be its own graph sorted by the same x values. I just need the y axis in graph builder to be able to change based on what is in the y_variables list (this list is options that the user selects).

gianpaolo
Level IV

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

hello,

i need to populate graph builder with some dispatch...

but im not able to pass the string "400" by script becasue the char " "

 

SendToReport(

Dispatch(

{},

"400",

ScaleBox,

 

can you help me , thank you

Gianpaolo

can

 

Gianpaolo Polsinelli
Bow
Bow
Level I

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

I tried this script but it failed to execute the insert into line. JMP 16.2 on Windows 10. How to fix it? 

Bow_0-1665176463111.png

 

Bo
Bow
Bow
Level I

Re: Can I use a list to populate the X and Y axis in graph builder when scripting?

adding index, eg, x_values[i] and y_values[i], solves the issue.  


Bo