%给没列数据赋变量名
TrueValue= data(:,1);
rfp= data(:,2);
svm= data(:,3);
sjwl= data(:,4);
LGBMR= data(:,5);
XGBOOST= data(:,6);
DTR= data(:,7);
KNR= data(:,8);
y=linspace(1,304,304)
%绘图
figure(1);
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,rfp,'k','LineWidth',1.2);
figure(2)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,svm,'b','LineWidth',1.2);
figure(3)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,sjwl,'c','LineWidth',1.2);
figure(4)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,LGBMR,'y','LineWidth',1.2);
figure(5)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,XGBOOST,'g','LineWidth',1.2);
figure(6)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,DTR,'k','LineWidth',1.2);
figure(7)
plot(y,TrueValue,'r','LineWidth',1.2);
hold on;
plot(y,KNR,'b','LineWidth',1.2);
部分输出结果(图6):
2、局部放大图绘制
初始数据图绘制完成后,调用放大函数,代码如下:
% start of program
function magnify(f1)
% magnify(f1)
% Figure creates a magnification box when under the mouse position when a button is pressed. Press '+'/'-' while
% button pressed to increase/decrease magnification. Press '>'/'<' while button pressed to increase/decrease box size.
% Hold 'Ctrl' while clicking to leave magnification on figure.
%
% Example:
% plot(1:100,randn(1,100),(1:300)/3,rand(1,300)), grid on,
% magnify;
% Included for completeness (usually in own file)
function [fig_pointer_pos, axes_pointer_val] = pointer2d(fig_hndl,axes_hndl)
%
%pointer2d(fig_hndl,axes_hndl)
%
%Returns the coordinates of the pointer (in pixels)
%in the desired figure (fig_hndl) and the coordinates
% in the desired axis (axes coordinates)
%
% Example:
% figure(1),
% hold on,
% for i = 1:1000,
% [figp,axp]=pointer2d;
% plot(axp(1),axp(2),'.','EraseMode','none');
% drawnow;
% end;
% hold off
% Rick Hindman - 4/18/01
if (nargin == 0), fig_hndl = gcf; axes_hndl = gca; end;
if (nargin == 1), axes_hndl = get(fig_hndl,'CurrentAxes'); end;
set(fig_hndl,'Units','pixels');
pointer_pos = get(0,'PointerLocation');%pixels {0,0} lower left
fig_pos = get(fig_hndl,'Position');%pixels {l,b,w,h}
function createfigure(X1, YMatrix1)
figure1 = figure;
axes1 = axes('Parent',figure1);
hold(axes1,'on');
plot1 = plot(X1,YMatrix1,'Parent',axes1,'LineWidth',1.2);
set(plot1(1),'DisplayName','real values','Color',[1 0 0]);
set(plot1(2),'DisplayName','predicted values','Color',[0 0 0]);
ylabel({'Value'});
xlabel({'Number'});
title({'Comparison of predicted value and real value of decision tree'});