函数来源为MATLAB | 如何使用MATLAB绘制雷达图(蜘蛛图)
名称 | 说明 | 备注 |
---|---|---|
‘Type’ | 用于指定每个轴的标签 | [‘Line’(默认)/‘Patch’] |
成图如下所示:
MATLAB实现代码如下:
clc
close all
clear
%% 导入数据
pathFigure= '.\Figures\' ;%% Example 1
X = randi([2,8],[4,7])+rand([4,7]);figure(1)
RC = radarChart(X ,'Type','Patch');
RC.RLim = [2,10]; % 范围
RC.RTick = [2,8:1:10]; % 刻度线
RC.PropName = {'Label1','Label2','Label3','Label4','Label5','Label6','Label7'};
RC.ClassName = {'A','B','C','D'};
RC = RC.draw();
RC.legend(); % 添加图例colorList=[78 101 155;138 140 191;184 168 207;231 188 198;253 207 158;239 164 132;182 118 108]./255;
for n=1:RC.ClassNumRC.setPatchN(n,'FaceColor',colorList(n,:),'EdgeColor',colorList(n,:))
endRC.setThetaTick('LineWidth',2,'Color',[.6,.6,.8]); % theta轴颜色设置
RC.setRTick('LineWidth',1.5,'Color',[.8,.6,.6]); % R轴颜色设置
RC.setPropLabel('FontSize',15,'FontName','Times New Roman','Color',[0,0,0]) % 属性标签
RC.setRLabel('FontSize',15,'FontName','Times New Roman','Color',[.8,0,0]) % R刻度标签
% RC.setBkg('FaceColor',[0.8,0.8,0.8]) % 圆形背景颜色
% RC.setRLabel('Color','none') % 圆形背景颜色str= strcat(pathFigure, "Figure1", '.tiff');
print(gcf, '-dtiff', '-r600', str);
成图如下所示:
MATLAB实现代码如下:
clc
close all
clear
%% 导入数据
pathFigure= '.\Figures\' ;%% Example 2
X = randi([2,8],[4,7])+rand([4,7]);figure(2)
RC=radarChart(X ,'Type','Line');
RC.PropName = {'Label1','Label2','Label3','Label4','Label5','Label6','Label7'};
RC.ClassName = {'A','B','C','D'};
RC=RC.draw();
RC.legend();colorList=[78 101 155;138 140 191;184 168 207;231 188 198;253 207 158;239 164 132;182 118 108]./255;
for n=1:RC.ClassNumRC.setPatchN(n,'Color',colorList(n,:),'MarkerFaceColor',colorList(n,:))
endRC.setThetaTick('LineWidth',2,'Color',[.6,.6,.8]); % theta轴颜色设置
RC.setRTick('LineWidth',1.5,'Color',[.8,.6,.6]); % R轴颜色设置
RC.setPropLabel('FontSize',15,'FontName','Times New Roman','Color',[0,0,0]) % 属性标签
RC.setRLabel('FontSize',15,'FontName','Times New Roman','Color',[.8,0,0]) % R刻度标签
% RC.setBkg('FaceColor',[0.8,0.8,0.8]) % 圆形背景颜色
% RC.setRLabel('Color','none') % 圆形背景颜色str= strcat(pathFigure, "Figure2", '.tiff');
print(gcf, '-dtiff', '-r600', str);
函数来源为MATLAB帮助-spider_plot
语法(Syntax):
spider_plot(P)spider_plot(P, Name, Value, ...)h = spider_plot(_)
输入变量:
输出变量:
名称-值对参数(Name-Value Pair Arguments):
名称 | 说明 | 备注 |
---|---|---|
AxesLabels | 用于指定每个轴的标签 | [自动生成(默认)/单元格的字符串/ ‘none’] |
AxesInterval | 用于更改显示在网页之间的间隔数 | [3(默认值)/ integer] |
AxesPrecision | 用于更改轴上显示的值的精度级别 | [1(默认)/ integer / vector] |
AxesDisplay | 用于更改显示轴文本的轴数。'None’或’one’可用于简化规范化数据的图形外观 | [‘none’(默认)/ “没有”/“一”/“数据”/“data-percent”] |
成图如下所示:
MATLAB实现代码如下:
clc
close all
clear
%% 导入数据
pathFigure= '.\Figures\' ;
%% Example 1
% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];% Spider plot
figure(1)
h = spider_plot(P,...'AxesLabels', {'S1', 'S2', 'S3', 'S4', 'S5'},...'FillOption', {'on', 'on', 'off'},...'FillTransparency', [0.2, 0.1, 0.1],...'AxesLimits', [1, 2, 1, 1, 1; 10, 8, 9, 5, 10],... % [min axes limits; max axes limits]'AxesPrecision', [0, 1, 1, 1, 1],...'LineStyle', {'--', '-', '--'},...'LineWidth', [1, 2, 3],...'AxesFont', 'Times New Roman',...'LabelFont', 'Times New Roman',...'AxesFontSize', 12,...'LabelFontSize', 12,...'AxesLabelsEdge', 'none');% Legend settings
hl = legend('D1', 'D2', 'D3', 'Location', 'northeast');
set(hl,'Box','off','FontSize',14,'Fontname', 'Times New Roman');str= strcat(pathFigure, "Figure1", '.tiff');
print(gcf, '-dtiff', '-r600', str);
成图如下所示:
MATLAB实现代码如下:
clc
close all
clear
%% 导入数据
pathFigure= '.\Figures\' ;
%% Example 2
% Initialize data points
D1 = [5 3 9 1 2 2 9 3 1 9 8 7 2 3 6];
D2 = [5 8 7 2 9 7 6 4 8 9 2 1 8 2 4];
D3 = [8 2 1 4 6 1 8 4 2 3 7 5 6 1 6];
P = [D1; D2; D3];% Spider plot
spider_plot(P,...'AxesLimits', [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;...10 10 10 10 10 10 10 10 10 10 10 10 10 10 10],...'AxesInterval', 5,...'AxesDisplay', 'one',...'AxesPrecision', 0,...'AxesLabelsRotate', 'on',...'AxesLabelsOffset', 0.1,...'AxesRadial', 'off',...'AxesFont', 'Times New Roman',...'LabelFont', 'Times New Roman',...'AxesFontSize', 12,...'LabelFontSize', 12,...'AxesLabelsEdge', 'none');% Legend settings
hl = legend('D1', 'D2', 'D3', 'Location', 'northeast');
set(hl,'Box','off','FontSize',14,'Fontname', 'Times New Roman');str= strcat(pathFigure, "Figure2", '.tiff');
print(gcf, '-dtiff', '-r600', str);
1.MATLAB | 如何使用MATLAB绘制雷达图(蜘蛛图)
2.MATLAB帮助-spider_plot