Hello,
I am trying to color curves in a specific way and I do not find a way...
Basically, I have a couple of curves that are grouped by a label. How can I display all the curves with a different color for each group ?
So far, I tried in Graph Builder putting the "label" put in the "overlay" part...But like that JMP considers all the curves of a group like being ONE curve.
I tried a more advanced thing using JSL (find the code below). I was able to generate the curves and access the different lines and color them independently, but I lose the link between the lines and the label.
In the example below: how can I get all the curves of Honda in red, those of Ford in Blue, and those of GM in purple ? (this assuming of course that I do not know a priori how many curves are in each group, and not how many groups there are).
Any ideas ?
// Generate a simple table as example
dt = New Table( "Untitled 9050",
Add Rows( 33 ),
New Column( "Time [years]",
Numeric,
Continuous,
Format( "Best", 2 ),
Set Values(
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
)
),
New Column( "car1",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values(
[0, 0.8, 1.6, 2.4, 3.2, 4, 4.8, 5.6, 6.4, 7.2, 8, 0, 1.2, 2.4, 3.6, 4.8,
6, 7.2, 8.4, 9.6, 10.8, 12, 0, 2.2, 4.4, 6.6, 8.8, 11, 13.2, 15.4, 17.6,
19.8, 22]
)
),
New Column( "car2",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Selected,
Set Values(
[0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 0, 1.4, 2.8, 4.2, 5.6, 7,
8.4, 9.8, 11.2, 12.6, 14, 0, 2.4, 4.8, 7.2, 9.6, 12, 14.4, 16.8, 19.2,
21.6, 24]
)
),
New Column( "car3",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values(
[0, 0.6, 1.2, 1.8, 2.4, 3, 3.6, 4.2, 4.8, 5.4, 6, 0, 1.6, 3.2, 4.8, 6.4,
8, 9.6, 11.2, 12.8, 14.4, 16, 0, 2.6, 5.2, 7.8, 10.4, 13, 15.6, 18.2,
20.8, 23.4, 26]
)
),
New Column( "car4",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values(
[0, 0.4, 0.8, 1.2, 1.6, 2, 2.4, 2.8, 3.2, 3.6, 4, 0, 1.8, 3.6, 5.4, 7.2,
9, 10.8, 12.6, 14.4, 16.2, 18, 0, 2.8, 5.6, 8.4, 11.2, 14, 16.8, 19.6,
22.4, 25.2, 28]
)
),
New Column( "Manufacturer",
Character( 16 ),
Nominal,
Set Values(
{"Honda", "Honda", "Honda", "Honda", "Honda", "Honda", "Honda", "Honda",
"Honda", "Honda", "Honda", "Ford", "Ford", "Ford", "Ford", "Ford",
"Ford", "Ford", "Ford", "Ford", "Ford", "Ford", "GM", "GM", "GM", "GM",
"GM", "GM", "GM", "GM", "GM", "GM", "GM"}
)
)
);
// stack the table
dt_Stack = dt << Stack(
columns( :car1, :car2, :car3, :car4 ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
// Create a graph
MyGraph = Graph Builder(
Variables( X( :Name( "Time [years]" ) ), Y( :Data ), Overlay( :Label ) ),
Elements(
Points( X, Y, Legend( 1 ), Jitter( 1 ) ),
Smoother( X, Y, Legend( 2 ) )
)
);
// Access the lines and their properties
GraphsRep = Report( MyGraph );
nbp = GraphsRep[FrameBox( 1 )] << segCount( "LineSeg" );
// Modify the lines colors
For( n = 1, n <= nbp, n++,
s = GraphsRep[FrameBox( 1 )] << FindSeg( LineSeg( n ) );
s << Line Color( "Black" );
);