如何制作开始/停止条形图?假设我有以下数据:
| 步 | 开始 | 停止 |
| 混合器 | 0 | 2 |
| 加热器1 | 1 | 12.3 |
| 喷油器1 | 4 | 4.5 |
| 混合器 | 6 | 8 |
| 加热器2 | 10.3 | 十三 |
| 喷油器1 | 12 | 12.5 |
| 加热器1 | 16 | 25.4 |
| 混合器 | 18 | 20 |
| 加热器2 | 23.4 | 三十 |
| 混合器 | 24 | 二十六 |
| 扇子 | 24 | 四十五 |
| 混合器 | 三十 | 40 |
...我想要制作这个图(仅仅是条形图):

使用 GraphBuilder 可以实现吗?(请注意,此图像是使用 PowerPoint 制作的模型)
数据探索与可视化回复:如何制作开始/停止条形图?你好@BHarris ,
我无法直接重现您在 PowerPoint 中呈现的内容,但我可能有一些与您想要的内容足够相似的内容:

与您的图像不同,不同的范围并非完全对齐,因为我需要为每个值范围提供一个唯一的标识符。
我认为可以放大这些栏以提高可读性。
您可以查看附加数据表中的脚本。
编辑:使用级别较少的 ID 列,条形图看起来更好:

两个图形脚本均保存在附加的数据表中。
回复:如何制作开始/停止条形图?不错的方法:)
作为覆盖的替代,还可以使用嵌套在 Y 轴上的 ID:

回复:如何制作开始/停止条形图?这两个选项都会产生大量空白,因为每个开/关都有自己的水平行,而在我的用例中可能会有很多开/关。条形图有一个红色三角形“重叠”设置,似乎应该可以工作,但即使在“满”时它似乎也不起作用,所以我希望可能有一个隐藏选项或 JSL 方法可以让条形图保持垂直对齐。
回复:如何制作开始/停止条形图?这是我创建图表的方法

Names Default To Here( 1 );
dt = Current Data Table();
gb = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :Start ), X( :Stop, Position( 1 ) ), Y( :Step ), Color( :Step ) ),
Elements( Points( X( 1 ), X( 2 ), Y, Legend( 12 ) ) ),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model(
12,
Properties( 5, {Marker( "FilledCircle" )}, Item ID( "Start", 1 ) ),
Properties( 6, {Marker( "FilledCircle" )}, Item ID( "Stop", 1 ) )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Start - Stop Chart" )} )
)
);
// Remove Start and Stop from legend
lgnd = gb << Get Legend Display;
items = lgnd << Get Items;
For Each( {item}, items,
If( item << Get Label == "Start" | item << Get Label == "Stop",
item << Set Visible( 0 )
)
);
// Set default Value Colors if not set
if( isEmpty(dt:step << get property( "value colors" )),
dt:step << set property( "value colors", "" );
);
// Get the colors to use
colors = dt:step << get property( "value colors" );
// Find the labels for the Y Axis
Summarize( dt, levels = by( :step ) );
// Add a Graphics Script to create the bars on the graph
fb = Report( gb )[framebox( 1 )];
fb << add graphics script(
// Get the colors to use
colors = dt:step << get property( "value colors" );
For Each Row(
cpoint = Contains( levels, :step ) - 1;
Fill Color( Num( Word( 3, Char( colors[cpoint + 1] ), " " ) ) );
Rect( :start, cPoint + .4, :stop, cPoint - .4, 1 );
);
);
回复:如何制作开始/停止条形图?有很多 JSL 选项可以实现类似这样的功能。如果您能弄清楚如何使用 Set Marker Expr(它实际上没有文档),那么它很可能是最好的选择。这是我使用 Set Marker Draw Expr 的快速方法,使用一个标记可以更简单,但使用两个标记可以让用户从两端“选择”行
Names Default To Here(1);
dt = New Table("Untitled 2",
Add Rows(12),
Compress File When Saved(1),
New Column("Step",
Character,
"Nominal",
Set Property("Value Colors", {"fan" = -15113984, "heater1" = -5682409, "heater2" = -40563, "injector1" = -29362, "mixer" = -13983232}),
Set Values({"mixer", "heater1", "injector1", "mixer", "heater2", "injector1", "heater1", "mixer", "heater2", "mixer", "fan", "mixer"})
),
New Column("Start",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([0, 1, 4, 6, 10.300000000000001, 12, 16, 18, 23.399999999999999, 24, 24, 30])
),
New Column("Stop",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([2, 12.300000000000001, 4.5, 8, 13, 12.5, 25.399999999999999, 20, 30, 26, 45, 40])
)
);
dt << Color or Mark by Column(:Step, Color(1), Marker(0));
gb = dt << Graph Builder(Variables(X(:Start), X(:Stop, Position(1)), Y(:Step), Color(:Step)),
Elements(Points(X(1), X(2), Y, Legend(7))),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
7,
Properties(0, {Marker("FilledSquare")}, Item ID("fan", 1)),
Properties(1, {Marker("FilledSquare")}, Item ID("heater1", 1)),
Properties(2, {Marker("FilledSquare")}, Item ID("heater2", 1)),
Properties(3, {Marker("FilledSquare")}, Item ID("injector1", 1)),
Properties(4, {Marker("FilledSquare")}, Item ID("mixer", 1))
)}
),
Dispatch({}, "400", LegendBox,
{Legend Position({7, [0, 1, 2, 3, 4, -1, -1]})}
)
)
);
frame = Report(gb)[FrameBox(1)];
seg = (frame << FindSeg(Marker Seg(1)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
Fill Color(Color Of(Row State(this row)));
Rect(x, y + 0.3, x + (:Stop[this row] - x) / 2 + 0.1, y - 0.3, 1)
)
);
seg = (frame << FindSeg(Marker Seg(2)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
Fill Color(Color Of(Row State(this row)));
Rect(x - (x - :Start[this row]) / 2 - 0.1, y + 0.3, x, y - 0.3, 1)
)
);
还有最有可能的选项,您可以大量修改数据以满足绘图需求。
回复:如何制作开始/停止条形图?哇,太棒了!
也许可以删除“/2”并绘制 2 个重叠的矩形。这样,即使起始点或终止点靠近边缘甚至超出图形范围,条形图仍会保持稳定。
回复:如何制作开始/停止条形图?基本上有无数种方法可以做到这一点。选择最适合需求的方法(或创建您自己的方法)。从开始到结束的矩形同时利用平均点可以轻松使用开始/停止标记,例如同时在中心添加额外的“标记”供用户点击。

回复:如何制作开始/停止条形图?而不是
Color Of(Row State(this row))
设置标记绘制 Expr()是否也可以使用通过 Color dropzone 定义的颜色主题?
是否有一个内置函数可以执行类似
legend = gb << get legend server;
items = {};
for each({list}, legend << get legend items, Insert Into(items, list));
gradient = Filter Each({item}, items, item << get Type == "Gradient");
if(not(N items(gradient)), Caption("no gradient"); stop());
gradient = gradient[1];
settings = gradient << Get Gradient Settings;
colorTheme = settings["Color Theme"];
colors = if(is list(colorTheme) ,
colorTheme[3],
Get Color Theme Detail( colorTheme )[3]);
colors = Matrix( Remove( colors, N Items( colors ) ) );
xs = ((1 :: N Items( colors[0, 1] )) - 1) / (N Items( colors[0, 1] ) - 1);
scale = settings["Scale Values"];
reverse = settings["Reverse Gradient"];
min = scale[If( reverse, 2, 1 )];
max = scale[If( reverse, 1, 2 )];
Eval(
Eval Expr(
col = Function( {x},
x2 = (x - Expr( min )) / (Expr( max - min ));
Eval List(
{Interpolate( x2, xs, Expr( colors[0, 1] ) ), Interpolate( x2, xs, Expr( colors[0, 2] ) ),
Interpolate( x2, xs, Expr( colors[0, 3] ) )}
);
)
)
);
回复:如何制作开始/停止条形图?有趣的是,“大小”是传输到
Set Marker Draw Expr
而颜色则不是。
回复:如何制作开始/停止条形图?JSL 矩形绘制方法确实创建了正确的图像,我很高兴了解它在 JMP 中的工作原理。我需要更多地尝试一下。
然而,我们失去了在条形图内单击以选择数据表中相应行的能力。我的数据集也相当大(数百万行),并被分成多个集合,每个集合由进入本地过滤器的第 4 列键入。这样,我们可以在同一窗口中快速查看任何结果集。我知道编写 JSL 代码以在本地数据过滤器发生变化时更新条形图是可能的,但这又增加了一层复杂性。
我想我会提交一个愿望清单项来修复/更新“条重叠”设置,以允许“ID”列在用作覆盖时将不同的行折叠为单个行。
大家的反馈都令人印象深刻!感谢所有回复的人!
回复:如何制作开始/停止条形图?现在,我将使用标记绘制表达式,并可能在“矩形”内添加额外的点。处理颜色有点烦人,因为我认为您无法在设置标记表达式函数中访问颜色,但您可以管理行状态,向表中添加颜色列或从标记中选择颜色。本地数据过滤器可能会出现一些问题,因此我可能会避免从标记中选择它们 -> 使用颜色列或行状态。
我认为标记绘制表达式应该能够很好地处理本地数据过滤器。我还没有测试过当你有大量数据时它的效果如何,但如果这成为一个问题,很可能可以进行优化。您还可以将条形的高度增加到 0.4(或非常接近 0.5 的值),它们不应该重叠。在这种情况下,我用矩形替换中间标记并直接从行状态中选择颜色
Names Default To Here(1);
dt = New Table("Demo",
Add Rows(12),
Compress File When Saved(1),
New Column("Step", Character, "Nominal", Set Values({"mixer", "heater1", "injector1", "mixer", "heater2", "injector1", "heater1", "mixer", "heater2", "mixer", "fan", "mixer"})),
New Column("Start", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 4, 6, 10.3, 12, 16, 18, 23.4, 24, 24, 30])),
New Column("Stop", Numeric, "Continuous", Format("Best", 12), Set Values([2, 12.3, 4.5, 8, 13, 12.5, 25.4, 20, 30, 26, 45, 40])),
New Column("G", Character, "Nominal", Set Values({"G1", "G1", "G1", "G1", "G1", "G1", "G2", "G2", "G2", "G2", "G2", "G2"}))
);
dt << New Column("Middle", Numeric, Continuous, Formula(
Mean(:Start, :Stop);
));
Column(dt, "Step") << Set Property("Value Colors", {"fan" = -15113984, "heater1" = -5682409, "heater2" = -40563, "injector1" = -29362, "mixer" = -13983232});
dt << Color or Mark by Column(:Step, Color(1), Marker(0));
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:Start), X(:Stop, Position(1)), X(:Middle, Position(1)), Y(:Step), Color(:Step)),
Elements(Points(X(1), X(2), X(3), Y, Legend(10))),
Local Data Filter(Add Filter(columns(:G))),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
10,
Properties(5, {Marker("Right Arrowhead")}, Item ID("Start", 1)),
Properties(6, {Marker("Left Arrowhead")}, Item ID("Stop", 1))
)}
),
Dispatch({}, "400", LegendBox, {Legend Position({10, [0, 1, 2, 3, 4, 5, 6, -1]})})
)
);
frame = Report(gb)[FrameBox(1)];
seg = (frame << FindSeg(Marker Seg(3)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
Fill Color(Color Of(row state));
Rect(:Start[this row], y + 0.4, :Stop[this row], y - 0.4, 1)
)
);


另外,当你开始使用这些时,JMP 也很容易崩溃。
回复:如何制作开始/停止条形图?9 月份会容易得多:)
回复:如何制作开始/停止条形图?在我给出的例子中,在<<添加图形脚本中使用 Rect(),您可以单击开始或停止数据点,它将选择行

回复:如何制作开始/停止条形图?如果可以,请注册 JMP 19 早期采用者计划,并对计划中的线元素增强功能提供反馈,这将提供另一种方法来实现此目的。
回复:如何制作开始/停止条形图?Jim,是的,我看到了,这是一个很好的解决方法。就我而言,有些条形图会很长,我们希望经常在时间线上放大,这意味着我必须在条形图上每隔一段时间绘制一大堆点。我还想让不太熟悉 JMP 的人使用这个绘图仪,因此强迫他们选择条形图端点需要培训并增加流程摩擦。
回复:如何制作起始/终止柱状图?JMP19 现已推出,它让创建类似这样的图表变得非常简单:

dt = New Table( "log",
Add Rows( 12 ),
New Column( "Step",
Character,
Set Values(
{"mixer", "heater1", "injector1", "mixer", "heater2", "injector1",
"heater1", "mixer", "heater2", "mixer", "fan", "mixer"}
)
),
New Column( "Start",
Set Values(
[0, 1, 4, 6, 10.3, 12, 16, 18, 23.4, 24, 24,30]
)
),
New Column( "Stop",
Set Values(
[2, 12.3, 4.5, 8, 13, 12.5, 25.4, 20, 30, 26,45, 40]
)
)
);
Graph Builder(
Size( 493, 262 ),
Graph Spacing( 4 ),
Variables( X( :Start ), X( :Stop, Position( 1 ) ), Y( :Step ), Color( :Step ) ),
Elements( Line( X( 1 ), X( 2 ), Y, Ordering( "Within Row" ) ) ),
);