- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Bar Graph and Line Graph overlay
How can I create same graph on JMP?
and I have the following raw data:
I hope somebody could help me out!
Thanks in advance!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
I take what I said back about both bars and lines in the same window. Below should give you the graph for which you are looking.
Names Default To Here( 1 );
// Create original data table.
dt = New Table( "Defects",
Add Rows( 14 ),
New Column( "Defects", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] ) ),
New Column( "A", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "B", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "C", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "D", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "E", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) )
);
// Transpose data table.
dtTrans = dt << Transpose( columns( :A, :B, :C, :D, :E ), Label( :Defects ), Output Table( "Transpose of Defects" ) );
// Add yield columns.
dtTrans << New Column( "Yield1",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
dtTrans << New Column( "Yield2",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - 2 * Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
// Create graph.
dtTrans << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :Label ),
Y( :Yield1, Side( "Right" ) ),
Y( :Yield2, Position( 1 ), Side( "Right" ) ),
Y( :Name( "1" ), Position( 1 ) ),
Y( :Name( "2" ), Position( 1 ) ),
Y( :Name( "3" ), Position( 1 ) ),
Y( :Name( "4" ), Position( 1 ) ),
Y( :Name( "5" ), Position( 1 ) ),
Y( :Name( "6" ), Position( 1 ) ),
Y( :Name( "7" ), Position( 1 ) ),
Y( :Name( "8" ), Position( 1 ) ),
Y( :Name( "9" ), Position( 1 ) ),
Y( :Name( "10" ), Position( 1 ) ),
Y( :Name( "11" ), Position( 1 ) ),
Y( :Name( "12" ), Position( 1 ) ),
Y( :Name( "13" ), Position( 1 ) ),
Y( :Name( "14" ), Position( 1 ) )
),
Elements(
Bar(
X,
Y( 3 ),
Y( 4 ),
Y( 5 ),
Y( 6 ),
Y( 7 ),
Y( 8 ),
Y( 9 ),
Y( 10 ),
Y( 11 ),
Y( 12 ),
Y( 13 ),
Y( 14 ),
Y( 15 ),
Y( 16 ),
Legend( 3 ),
Bar Style( "Stacked" ),
Summary Statistic( "Mean" )
),
Line( X, Y( 1 ), Y( 2 ), Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch( {}, "Yield1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch( {}, "400", ScaleBox, {Legend Model( 4, Properties( 0, {Line Width( 3 )} ), Properties( 1, {Line Width( 3 )} ) )} ),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Sample Trend" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Defect Rate" )} ),
Dispatch( {}, "Y r title", TextEditBox, {Set Text( "Yield" )} )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
Hi Switzal87
In JMP, all columns must be of the same data type, so it is not possible to have both defect and yield data in the same column. So the first thing you must do is transpose your defect data. Once you have a transpose of the defect data, you can add calculated columns for yield, and then create something similar to your example using Graph Builder. It may be possible to create something with both bars and lines in the same window, but I am not certain how to do this. The example below should get you close.
Names Default To Here( 1 );
// Create original data table.
dt = New Table( "Defects",
Add Rows( 14 ),
New Column( "Defects",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] )
),
New Column( "A", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "B", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "C", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "D", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "E", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
);
// Transpose data table.
dtTrans = dt << Transpose( columns( :A, :B, :C, :D, :E ), Label( :Defects ), Output Table( "Transpose of Defects" ) );
// Create graph.
dtTrans << New Column( "Yield1",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
dtTrans << New Column( "Yield2",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - 2 * Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
dtTrans << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :Label ),
Y( :Yield1 ),
Y( :Yield2, Position( 1 ) ),
Y( :Name( "1" ) ),
Y( :Name( "2" ), Position( 2 ) ),
Y( :Name( "3" ), Position( 2 ) ),
Y( :Name( "4" ), Position( 2 ) ),
Y( :Name( "5" ), Position( 2 ) ),
Y( :Name( "6" ), Position( 2 ) ),
Y( :Name( "7" ), Position( 2 ) ),
Y( :Name( "8" ), Position( 2 ) ),
Y( :Name( "9" ), Position( 2 ) ),
Y( :Name( "10" ), Position( 2 ) ),
Y( :Name( "11" ), Position( 2 ) ),
Y( :Name( "12" ), Position( 2 ) ),
Y( :Name( "13" ), Position( 2 ) ),
Y( :Name( "14" ), Position( 2 ) )
),
Elements(
Position( 1, 1 ),
Line(
X,
Y( 1 ),
Y( 2 ),
Legend( 12 ),
Row order( 0 ),
Summary Statistic( "Mean" )
)
),
Elements(
Position( 1, 2 ),
Bar(
X,
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Y( 6 ),
Y( 7 ),
Y( 8 ),
Y( 9 ),
Y( 10 ),
Y( 11 ),
Y( 12 ),
Y( 13 ),
Y( 14 ),
Legend( 10 ),
Bar Style( "Stacked" ),
Summary Statistic( "Sum" )
)
),
SendToReport(
Dispatch( {}, "Yield1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch( {}, "1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
12,
Properties( 0, {Line Width( 3 )} ),
Properties( 1, {Line Width( 3 )} )
)}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Yield" )} ),
Dispatch( {}, "Y 1 title", TextEditBox, {Set Text( "Defect Rate" )} )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
Cool! not the exact output that I want but still closer!
When I run the code I have the following graph:
Thanks a lot robot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
Is there a continuing issue? When I run Robot's code I get the following graph, which is exactly in the style you shown.
The graph you displayed has a Y Grouping that is splitting the bar charts and the line charts, not letting them overlay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
I take what I said back about both bars and lines in the same window. Below should give you the graph for which you are looking.
Names Default To Here( 1 );
// Create original data table.
dt = New Table( "Defects",
Add Rows( 14 ),
New Column( "Defects", Numeric, Continuous, Format( "Best", 12 ), Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] ) ),
New Column( "A", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "B", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "C", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "D", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) ),
New Column( "E", Numeric, Continuous, Format( "Percent", 12, 2 ), Formula( Random Uniform( 0, 0.002 ) ) )
);
// Transpose data table.
dtTrans = dt << Transpose( columns( :A, :B, :C, :D, :E ), Label( :Defects ), Output Table( "Transpose of Defects" ) );
// Add yield columns.
dtTrans << New Column( "Yield1",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
dtTrans << New Column( "Yield2",
Numeric,
Continuous,
Format( "Percent", 12, 2 ),
Formula(
1 - 2 * Sum(
:Name( "1" ),
:Name( "2" ),
:Name( "3" ),
:Name( "4" ),
:Name( "5" ),
:Name( "6" ),
:Name( "7" ),
:Name( "8" ),
:Name( "9" ),
:Name( "10" ),
:Name( "11" ),
:Name( "12" ),
:Name( "13" ),
:Name( "14" )
)
)
);
// Create graph.
dtTrans << Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :Label ),
Y( :Yield1, Side( "Right" ) ),
Y( :Yield2, Position( 1 ), Side( "Right" ) ),
Y( :Name( "1" ), Position( 1 ) ),
Y( :Name( "2" ), Position( 1 ) ),
Y( :Name( "3" ), Position( 1 ) ),
Y( :Name( "4" ), Position( 1 ) ),
Y( :Name( "5" ), Position( 1 ) ),
Y( :Name( "6" ), Position( 1 ) ),
Y( :Name( "7" ), Position( 1 ) ),
Y( :Name( "8" ), Position( 1 ) ),
Y( :Name( "9" ), Position( 1 ) ),
Y( :Name( "10" ), Position( 1 ) ),
Y( :Name( "11" ), Position( 1 ) ),
Y( :Name( "12" ), Position( 1 ) ),
Y( :Name( "13" ), Position( 1 ) ),
Y( :Name( "14" ), Position( 1 ) )
),
Elements(
Bar(
X,
Y( 3 ),
Y( 4 ),
Y( 5 ),
Y( 6 ),
Y( 7 ),
Y( 8 ),
Y( 9 ),
Y( 10 ),
Y( 11 ),
Y( 12 ),
Y( 13 ),
Y( 14 ),
Y( 15 ),
Y( 16 ),
Legend( 3 ),
Bar Style( "Stacked" ),
Summary Statistic( "Mean" )
),
Line( X, Y( 1 ), Y( 2 ), Legend( 4 ), Row order( 0 ), Summary Statistic( "Mean" ) )
),
SendToReport(
Dispatch( {}, "1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch( {}, "Yield1", ScaleBox, {Format( "Percent", 12, 2 )} ),
Dispatch( {}, "400", ScaleBox, {Legend Model( 4, Properties( 0, {Line Width( 3 )} ), Properties( 1, {Line Width( 3 )} ) )} ),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Sample Trend" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Defect Rate" )} ),
Dispatch( {}, "Y r title", TextEditBox, {Set Text( "Yield" )} )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Bar Graph and Line Graph overlay
thanks for the great help!