如何用Matlab画出漂亮的曲线图?
论文来源:
Chenliang Liu, Kai Wang, Yalin Wang, Xiaofeng Yuan. Learning deep multi-manifold structure feature representation for quality prediction with an industrial application. IEEE Transactions on Industrial Informatics, early access, doi: 10.1109/TII.2021.3130411.
https://ieeexplore.ieee.org/document/9626456
详细用法:
subplot函数用法
plot
hold on
xlabel
text
legend
set
%导入数据
load('y_test.mat')
load('y_pred_mnn.mat')
load('y_pred_sae.mat')
load('y_pred_laes.mat')
load('y_pred_smmae.mat')
% 为了方面画四个小图,在前面统一设置
% 得到测试集样本的长度
l_test=length(y_test);
% 真实值 “o” 的大小
o_markersize = 2;
% 预测值 “.” 的大小
dian_markesize = 11;
% 线的宽度
linewidth = 1;
% 所有字的大小
fontsize_all = 14;
% 插入文本字的大小
text_fontsize = 14;
% 画2*2的四个图 如后面结果所示
% 2*2的第一个图(左上角)
subplot(2,2,1)
% 计算RMSE的值
rmse = norm(y_test-y_pred_mnn)/sqrt(l_test)
% 计算R2的值
R2 = 1 - norm(y_test-y_pred_mnn)^2/norm(y_test - mean(y_test))^2
% 真实值的曲线
plot(1:l_test,y_test,'o-','linewidth',linewidth,'Markersize',o_markersize,'Color','r');
% 为了区分真实值和预测值曲线的形状 所以后面继续用plot情况下,需要用 “hold on” 使图像固定
hold on
% 预测值的曲线
plot(1:l_test,y_pred_mnn,'.-','linewidth',linewidth,'Markersize',dian_markesize,'Color','[0.1 0.1 0.44]');
% X轴显示的标签
xlabel('Sample number');
% y轴显示的标签
ylabel('Output value');
% 插入文本
text(20,0.1,'(a)','Fontname', 'Times New Roman','Fontsize'