turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- scripting a bar chart in graph builder

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 26, 2017 1:55 PM
(1552 views)

Hello. I am scripting a bar chart in graph builder because using a standard chart does not eliminate empty bars where as the graph builder does. I am allowing for the use of continuous modeling types as an X factor. Let me explain how I am approaching this.

The user selects some columns by which to plot a bar chart. I create the chart using graph builder and the first column selected. Then if there are more than one columns selected, I go in and <<add variables to the graph builder. This works exactly as I want it except when one of the selected columns is continuous. Then the graph builder replaces the entire X with the continuous variable and says there are more variables there but it is only plotting versus the one. When I create the chart manually like this by changing the continuous variable to ordinal, it works the way I want it. So I change each continuous column to oridinal but the graph still does not add the variable but replaces it.

Does anyone have any ideas how I can make this work the way I want it? Here is a simplified version of my script:

myWin = Column Dialog( FactorCol = Col List( "Multivariate Factor(s)" ) ); myFactor = myWin["FactorCol"]; myPlot = Graph Builder( Show Control Panel( 0 ), Show Legend( 0 ), Variables( X( Eval( myFactor[1] ) ), Y( yCol ), Color( Eval( myColor ) ) ), Elements( Bar( X, Y, Summary Statistic( "Std Dev" ), Label( "Label by Value" ) ) ), SendToReport( Dispatch( {}, ScaleBox, {Label Row( 1, {Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )} )} ) ) ); //If there is more than one factor then need to add variables to the graph If( N Items( myFactor ) > 1, myRep = Report( myPlot )[Graph Builder Box( 1 )]; For( j = 2, j <= N Items( myFactor ), j++, xcol = Column( dtmm, myFactor[j] ); If( xcol << Get Modeling Type == "Continuous", //set a column property so I can change it back later xcol << Set Property( "change", 1 ); xcol << Modeling Type( "Ordinal" ); ); myRep << Add Variable( {xcol, Role( "X" ), Position( 1 )} ); ); //now I have to adjust all the x-axis for the way I want it For( j = 1, j <= N Items( myFactor ), j++, Report( myPlot )[Axisbox( 1 )] << {Label Row( j, {Automatic Tick Marks( 0 ), Show Major Ticks( 1 ), Lower Frame( 1 ), Tick Mark Style( "Long Divider" )} )} ); );

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 27, 2017 11:06 AM
(2960 views)

Solution

Actually, I figured out how to do this by checking the variables of the graph builder box step by step. If the column is continuous, I change it to ordinal and when adding a variable, you have to add an inner position term. Here is the pertinant script bit.

//graph builder can not add factors unless they are ordinal or nominal //so if it is continuous, change to ordinal, and set a column property to change back later If( xcol << Get Modeling Type == "Continuous", xcol << Set Property( "change", {1} ); xcol << Modeling Type( "Ordinal" ); myRep << Add Variable( {xcol, Role( "X" ), Position( 1 ), Inner Position[i]} ), , myRep << Add Variable( {xcol, Role( "X" ), Position( 1 )} ) );

This does exactly what I want it to do.

H

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 27, 2017 3:59 AM
(1532 views)

I did this by building the plot I wanted manually and looking at the code. I used a loop to build up the text string bit by bit for each column.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 27, 2017 7:24 AM
(1522 views)

Thank you. Yes, I know creating a string script is an option but I am always reluctant to do that. But it may be necessary in this case. I am disappointed that is the case.

best

H

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 27, 2017 11:06 AM
(2961 views)

Actually, I figured out how to do this by checking the variables of the graph builder box step by step. If the column is continuous, I change it to ordinal and when adding a variable, you have to add an inner position term. Here is the pertinant script bit.

//graph builder can not add factors unless they are ordinal or nominal //so if it is continuous, change to ordinal, and set a column property to change back later If( xcol << Get Modeling Type == "Continuous", xcol << Set Property( "change", {1} ); xcol << Modeling Type( "Ordinal" ); myRep << Add Variable( {xcol, Role( "X" ), Position( 1 ), Inner Position[i]} ), , myRep << Add Variable( {xcol, Role( "X" ), Position( 1 )} ) );

This does exactly what I want it to do.

H