你好,
我正在嘗試以特定的方式為曲線著色,但沒有找到方法......
基本上,我有幾條按標籤分組的曲線。 如何為每組顯示不同顏色的所有曲線?
到目前為止,我嘗試在圖形生成器中將“標籤”放入“覆蓋”部分......但是像這樣,JMP 將一組曲線視為一條曲線。
我使用 JSL 嘗試了更高級的方法(找到下面的代碼)。 我能夠生成曲線並訪問不同的線條並獨立地為它們著色,但我失去了線條和標籤之間的鏈接。
在下面的例子中:如何獲得本田的所有曲線為紅色,福特的曲線為藍色,通用汽車的曲線為紫色? (當然,這是假設我事先不知道每組中有多少條曲線,也不知道有多少組)。
有任何想法嗎 ?
// 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" );
);四點:
腳本編寫
@XanGregg您真正想要的是使用 JSL 創建或修改的一組圖而不是一個大圖表,這可能是正確的。 下面有兩件事可以嘗試。
繪製線條
我很難想像您想要創建的圖表,聽起來像是一個圖表上有很多線條和一頁長的圖例。 使用透視數據,下面腳本中的頂部圖表為按製造商著色的每輛汽車創建線條。只有 5 種線條樣式可供使用,除了顏色之外,您無法識別圖例中的汽車類型。也許您可以使用此圖表來識別汽車的製造商,然後使用第二個圖表按製造商分組或包裝,然後按汽車著色? 這是該腳本中的底部圖表,請注意,您可以單擊一條線並在底部圖表中查看它的標識。
//Start with the long table in your first post.<BR />New Window("Two Graphs",
Graph Builder(
Size( 600, 400 ),
Show Control Panel( 0 ),
Variables(
X( :Name( "Time [years]" ) ),
Y( :Data ),
Overlay( :Name( "Man-Car" ) ),
Color( :Manufacturer )
),
Elements( Line( X, Y, Legend( 20 ) ) ),
SendToReport(
Dispatch(
{},
"Time [years]",
ScaleBox,
{Label Row( Show Major Grid( 1 ) )}
),
Dispatch( {}, "Data", ScaleBox, {Label Row( Show Major Grid( 1 ) )} )
)
),
Graph Builder(
Size( 604, 448 ),
Show Control Panel( 0 ),
Variables(
X( :Name( "Time [years]" ) ),
Y( :Data ),
Wrap( :Manufacturer ),
Overlay( :Label )
),
Elements( Line( X, Y, Legend( 20 ) ) ),
SendToReport(
Dispatch(
{},
"Time [years]",
ScaleBox,
{Label Row( Show Major Grid( 1 ) )}
),
Dispatch( {}, "Data", ScaleBox, {Label Row( Show Major Grid( 1 ) )} )
)
)
)
傳奇
為了使圖例同時顯示製造商和汽車,請創建一個列,將製造商名稱與汽車名稱連接起來。例如:
New Column( "Man:Car",
Character,
"Nominal",
Formula( :Manufacturer || " " || :Label ),
Set Selected,
Set Display Width( 108 )
)
改為繪製點
另一個想法:您是否可以將每條曲線總結為您實際想要可視化的內容,而不是嘗試顯示那麼多線?對於[我假設]簡化線示例,您可以為每輛車繪製單獨的點,顯示斜率和截距。圖表上的 2000 個點比 2000 條線更容易解釋。 但在某些時候我仍然放棄了這個傳說)。在這裡,我從長表開始,按照上面創建的 Man-Car 列進行擬合模型,然後將估計表保存為組合表,按術語拆分錶,然後繪製圖表:
