I am trying to overlay datapoints from a column and a function line in Graph Builder. However, whenever I place the variables on the same axis and overlay them, I end up with either:
- both the datapoints and the function drawn as points, or
- both drawn as lines.
What I want is simple:
- the column data should appear as points, and
- the function should appear as a line,
overlaid in the same graph.
Below is a JSL script that generates a small sample table with two random columns and a function column. Here, Column 1 and Column 2 are random values, and the function column is a polynomial function of Column 1. When I use Graph Builder, JMP places them on separate graphs unless I overlay them, and once I overlay, Graph Builder forces all Y variables to share the same element type.
It appears that Graph Builder cannot mix points and lines when multiple Y variables share the same axis in an overlay.
Attached is the plot that I currently see, showing how Graph Builder places the function and datapoints on separate axes or forces them into the same element type when overlaid. Here I am using the version JMP 18.
Does anyone know whether there is a way to overlay a function line and datapoints on the same graph in Graph Builder while keeping different element types? Or is Graph Builder limited in this case?
New Table( "Function_plot",
Add Rows( 10 ),
New Script(
"plot_function",
Graph Builder(
Variables( X( :Column 1 ), Y( :function ), Y( :Column 2 ) ),
Elements( Position( 1, 1 ), Formula( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch( {}, "400", LegendBox,
{Legend Position( {13, [1], 7, [0]} )}
)
)
)
),
New Column( "Column 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [3, 1, 5, 9, 3, 12, 15, 19, 21, 17] ),
Set Display Width( 53 )
),
New Column( "Column 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [22, 76, 34, 19, 9, 45, 78, 63, 19, 5] ),
Set Display Width( 53 )
),
New Column( "function",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :Column 1 ^ 3 + 5 ),
Set Selected,
Set Display Width( 47 )
)
);
Graph Builder(
Variables( X( :Column 1 ), Y( :function ), Y( :Column 2 ) ),
Elements( Position( 1, 1 ), Formula( X, Y, Legend( 13 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 7 ) ) ),
SendToReport(
Dispatch( {}, "400", LegendBox, {Legend Position( {13, [1], 7, [0]} )} )
)
);