绘图仪:雷达
雷达
雷达图简洁地显示多个值。雷达图也称为蜘蛛图或星图。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 78, 83, 84, 76, 43 },
{ 100, 50, 70, 60, 90 }
};
plt.AddRadar(values);
// improve plot styling
plt.Frameless();
plt.Grid(enable: false);
plt.SaveFig("radar_quickstart.png");
直轴线
将“轴类型”更改为“多边形”,以显示具有直线的雷达图。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 78, 83, 84, 76, 43 },
{ 100, 50, 70, 60, 90 }
};
var radarPlot = plt.AddRadar(values);
radarPlot.AxisType = RadarAxis.Polygon;
plt.SaveFig("radar_straightLines.png");
没有轴线
雷达图也可以没有绘制的轴。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 78, 83, 84, 76, 43 },
{ 100, 50, 70, 60, 90 }
};
var radarPlot = plt.AddRadar(values);
radarPlot.AxisType = RadarAxis.None;
radarPlot.ShowAxisValues = false;
plt.SaveFig("radar_noLines.png");
标记类别
类别标签可以显示在雷达图上。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 5, 3, 10, 15, 3, 2, 256 },
{ 5, 2, 10, 10, 1, 4, 252 },
};
var radar = plt.AddRadar(values, independentAxes: true);
radar.CategoryLabels = new string[] { "Wins", "Poles", "Podiums", "Points Finishes", "DNFs", "Fastest Laps", "Points" };
radar.GroupLabels = new[] { "Sebastian Vettel", "Fernando Alonso" };
radar.ShowAxisValues = false;
// customize the plot
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*/
plt.SaveFig("radar_labelCategory.png");
标记值
标签可以显示在雷达图的臂上。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 5, 3, 10, 15, 3, 2 },
{ 5, 2, 10, 10, 1, 4 },
};
var radar = plt.AddRadar(values);
radar.CategoryLabels = new string[] { "Wins", "Poles", "Podiums", "Points Finishes", "DNFs", "Fastest Laps" };
radar.GroupLabels = new string[] { "Sebastian Vettel", "Fernando Alonso" };
// customize the plot
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*/
plt.SaveFig("radar_labelValue.png");
可自定义多边形轮廓
每个雷达图轮廓的厚度可以定制。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 5, 3, 10, 15, 3, 2 },
{ 5, 2, 10, 10, 1, 4 },
};
var radar = plt.AddRadar(values);
radar.OutlineWidth = 3;
radar.GroupLabels = new string[] { "Sebastian Vettel", "Fernando Alonso" };
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*/
plt.SaveFig("radar_customizePolygonOutline.png");
带有图像的类别
图像可以显示在雷达图的臂上。使用图像时,标签将被忽略,因此设置它们将无效。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 5, 15, 3, 2 },
{ 5, 10, 1, 4 },
};
var radar = plt.AddRadar(values);
radar.CategoryImages = CategoryImages;
radar.GroupLabels = new string[] { "Sebastian Vettel", "Fernando Alonso" };
// customize the plot
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*/
plt.SaveFig("radar_iconValue.png");
独立轴缩放
轴比例可以是独立的,允许使用不同的比例显示每个类别的值。启用独立轴模式时,轴限制会自动调整以适应数据范围。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = { { 5, 3, 10, 15, 3, 2, 256 }, { 5, 2, 10, 10, 1, 4, 252 }, };
var radar = plt.AddRadar(values, independentAxes: true);
radar.CategoryLabels = new string[] { "Wins", "Poles", "Podiums", "Points Finishes", "DNFs", "Fastest Laps", "Points" };
radar.GroupLabels = new string[] { "Sebastian Vettel", "Fernando Alonso" };
// customize the plot
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*/
plt.SaveFig("radar_axisScaling.png");
定义的轴限制
默认情况下,具有独立轴限制的雷达图使用适合数据的比例,但可以通过定义每个轴的最大值来控制比例。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 5, 3, 10, 15, 3, 2, 256 },
{ 5, 2, 10, 10, 1, 4, 252 },
};
double[] maxValues = { 13, 15, 17, 15, 10, 10, 413 };
var radar = plt.AddRadar(values, independentAxes: true, maxValues: maxValues);
radar.CategoryLabels = new string[] { "Wins", "Poles", "Podiums", "Points Finishes", "DNFs", "Fastest Laps", "Points" };
radar.GroupLabels = new string[] { "Sebastian Vettel", "Fernando Alonso" };
// customize the plot
plt.Title("2010 Formula One World Championship");
plt.Legend();
/* Data represents the 2010 Formula One World Championship
* https://en.wikipedia.org/wiki/2010_Formula_One_World_Championship
* Note: Alonso did not finish (DNF) in the Malaysian GP, but was included
* here because he completed >90% of the race distance.
*
* Max values are based on https://en.wikipedia.org/wiki/List_of_Formula_One_World_Drivers%27_Champions.
*/
plt.SaveFig("radar_axisLimits.png");
定制
雷达图支持线条颜色和宽度的定制。
var plt = new ScottPlot.Plot(600, 400);
double[,] values = {
{ 78, 83, 84, 76, 43 },
{ 100, 50, 70, 60, 90 }
};
var radar = plt.AddRadar(values);
radar.WebColor = System.Drawing.Color.Red;
radar.LineWidth = 3;
plt.SaveFig("radar_customization.png");