cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Pro extension simulates Bayesian Optimization runs. Prediction formulas stand in for experimental results. Run simulations and compare results. Download and use the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SabinaS
Level I

Spider graph

Hi All, I'm a new user of this software. I have the version 18.0. Is it possible to build a spider plot? Many thanks!

13 REPLIES 13
ALISIDDIQUI
Level II

Re: Spider graph

Hi Christian

Finally I got the early adopter version. 

However, this option is still not available in the 2027 \EA under graph builder...

Thanks for letting me know how to access this feature.

Best regards

A

EA-graphbuilder.png

 

Re: Spider graph

christianz_0-1794295833168.png

  1. Select Pie Chart element
  2. Set Pie Style to Radar
ALISIDDIQUI
Level II

Re: Spider graph

Thanks for your help. I didnt see the drop down option.

I'll play with it and see how its working.

Best regards

A

lwencx
Level III

Re: Spider graph

可以用JSL绘制,可以选择线性图或面积图,供参考

lwencx_0-1796172024841.png

lwencx_2-1796172127661.pnglwencx_3-1796172147087.png

// 打开文件选择对话框
filePath = Pick File( "请选择文件", "$desktop", {"All Files|*", "JMP Files|jmp", "JSL Files|jsl"}, 1, 0 );
 
// 检查路径是否有效再执行打开
If( Is Empty( filePath ) | filePath == "",
Stop();  // 直接终止,避免后续错误
);
// 打开文件
::dt = Open( filePath );
 
 
// 获取当前活动数据表
//dt = Current Data Table();
 
// 获取文件名(含扩展名)
//fileName = dt << Get Name;
n = N Rows( dt );
colNames = Column( dt, "类别" ) << Get Values;
::chart_type = "XLD";
New Window( "雷达图",
V List Box(
 
H List Box(
lineup = Lineup Box( N Col( 4 ), Spacing( 4 ),
Button Box( "线雷达图",
::chart_type = "XLD";
XLDT();
),
Button Box( "面积雷达图",
::chart_type = "MLD";
MJLDT();
),
nb = Number Edit Box( 1 ),
sb = Spin Box( Function( {value}, nb << Increment( value ) ), nb << Set Increment( 1 ) ),
::nb_val = nb << Get;
 
)
),
nb_txet = nb << Get;
allCols = dt << Get Column Names( String );
secondCol = allCols[nb_txet + 1];
yMax = Column( dt, secondCol ) << Get Values;
MaxData = Max( yMax );
 
::gbox = Graph Box(
Frame Size( 510, 500 ),
X Scale( 0, MaxData * 2 + 2 ),
Y Scale( 0, MaxData * 2 + 2 ),
X Axis( Show Major Grid( 0 ), Show Minor Grid( 0 ) ), //删除网格线
Y Axis( Show Major Grid( 0 ), Show Minor Grid( 0 ) ),
Suppress Axes, //删除坐标轴及轴标签
);
 
), 
 
);
nb << Set Function( OnNbChange );   // 手动输入时触发
OnNbChange = Function( {value},
::nb_val = nb << Get;
allCols = dt << Get Column Names( String );
secondCol = allCols[::nb_val + 1];
If(
::chart_type == "XLD", XLDT(),                            // 线雷达图
::chart_type == "MLD", MJLDT(),                            // 面积雷达图
);
);
 
 
 
ZB = Function( {}, 
 
For( j = 1, j <= MaxData, j++,
Pen Color( "Black" );
Line Style( 1 );              // 边框线型
Pen Size( 1 );                // 边框粗细
Circle( {MaxData + 1, MaxData + 1}, j ) //Circle( {x, y}, r,Fill )圆心坐标+半径
;
);
 
 
For( k = 1, k <= n, k++,
angle = (k - 1) * (2 * Pi() / n);       // 等角度分割
x2 = MaxData + 1 + MaxData * Cos( angle );            // 终点 x
y2 = MaxData + 1 + MaxData * Sin( angle );            // 终点 y
Pen Color( "Black" );
Line Style( 1 );
Pen Size( 0.1 );
Line( {MaxData + 1, MaxData + 1}, {x2, y2} );            // 从圆心到终点
 
xLabel = MaxData + 1 + (MaxData + 0.6) * Cos( angle );   //标签与线端的额外偏移距离
yLabel = MaxData + 1 + (MaxData + 0.9) * Sin( angle );
labelText = Column( dt, "类别" )[k];
Text Color( "Black" );
Text Size( 14 );
Text( {xLabel, yLabel}, labelText );
);
);
 
 
MJLDT = Function( {},
::gbox << Set Graphics Script(
ZB();
x1List = [];
y1List = [];
For( m = 1, m <= n, m++,
dataVal = Column( dt, secondCol )[m];
angle1 = (m - 1) * (2 * Pi() / n);       // 等角度分割
px = MaxData + 1 + dataVal * Cos( angle1 );              // 按数据值缩放半径
py = MaxData + 1 + dataVal * Sin( angle1 );
Insert Into( x1List, px );   // 逐个插入列表(2)
Insert Into( y1List, py );
 
px1 = MaxData + 1 + (dataVal + 0.3) * Cos( angle1 );              // 按数据值缩放半径
py1 = MaxData + 1 + (dataVal + 0.3) * Sin( angle1 );
labelText1 = Column( dt, secondCol )[m];
Text Color( "Red" );
Text Font( "Segoe UI", 10, "Bold" );
Text( {px1, py1}, labelText1 );
);
 
Fill Color( "Red" );
Transparency( 0.5 );
Polygon( x1List, y1List );
Text Color( "Red" );
Transparency( 1 );
Text Font( "Segoe UI", 10, "Bold" );
Text( {MaxData * 2, MaxData * 2+1.5}, secondCol );
 
)
);
colorList = {"Red", "Blue", "Green", "Orange", "Purple", "Cyan", "Magenta", "Brown", "Pink", "Dark Green"};
XLDT = Function( {},
::gbox << Set Graphics Script(
 
        // ── 绘制各系列折线 ────────────────────────────────────────
For( s = 1, s <= ::nb_val, s++,
secondCol = allCols[s + 1];
ZB();
x1List = [];
y1List = [];
 
For( m = 1, m <= n, m++,
dataVal = Column( dt, secondCol )[m];
angle1 = (m - 1) * (2 * Pi() / n);           // 等角度分割
px = MaxData + 1 + dataVal * Cos( angle1 );   // 按数据值缩放半径
py = MaxData + 1 + dataVal * Sin( angle1 );
Insert Into( x1List, px );
Insert Into( y1List, py );
 
px1 = MaxData + 1 + (dataVal + 0.3) * Cos( angle1 );
py1 = MaxData + 1 + (dataVal + 0.3) * Sin( angle1 );
labelText1 = Column( dt, secondCol )[m];
 
lineColor = colorList[Mod( s - 1, N Items( colorList ) ) + 1];
Text Color( lineColor );                       // 标签颜色与线条一致
Text Font( "Segoe UI", 10, "Bold" );
Text( {px1, py1}, labelText1 );
);
 
lineColor = colorList[Mod( s - 1, N Items( colorList ) ) + 1]; // 循环取色
Insert Into( x1List, x1List[1] );  // 闭合折线
Insert Into( y1List, y1List[1] );
Pen Color( lineColor );
Line Style( 0 );
Pen Size( 2 );
Transparency( 1 );
Line( x1List, y1List );            // 连接所有数据点(已闭合)
);
 
        // ── 绘制图例 ──────────────────────────────────────────────
legendX = 0.5;    // 图例起始 X 坐标(可按画布尺寸调整)
legendY = 0.5;    // 图例起始 Y 坐标(从顶部开始)
legendStep = 0.5;    // 每条图例的垂直间距
legendLineW = 0.4;    // 图例色块线段长度
legendTextOX = 0.3;    // 文字相对线段右端的偏移
 
For( s = 1, s <= ::nb_val, s++,
legendColor = colorList[Mod( s - 1, N Items( colorList ) ) + 1];
seriesName = allCols[s + 1];                      // 系列名称取列名
ly = legendY + (s - 1) * legendStep;      // 当前图例行 Y 坐标
 
// 绘制色块线段
Pen Color( legendColor );
Pen Size( 12 );
Line Style( 0 );
Line( {legendX, ly}, {legendX + legendLineW, ly} );
 
            // 绘制系列名称文字
Text Color( legendColor );
Text Font( "Segoe UI", 10, "Bold" );
Text( {legendX + legendLineW + legendTextOX, ly - 0.2}, seriesName );
);
 
)
);

Recommended Articles