1. 程式人生 > 其它 >兩條matlab 讀取mat檔案並繪圖及修改座標軸 圖例 新增標註

兩條matlab 讀取mat檔案並繪圖及修改座標軸 圖例 新增標註

close all;
clear all;
clc;
%**注:直接執行將本檔案與匯出資料放置在同一資料夾執行,可得設定好的.fig檔案
%**選擇編輯-幅值圖窗即可圖片複製到word/visio等檔案中處理

m=load('6-1.mat');
n=load('6-2.mat');
a=m.DataExport.line_1.x;
b=m.DataExport.line_1.y;
c=n.DataExport.line_1.x;
d=n.DataExport.line_1.y;

figure(1)
yyaxis left;
plot (a,b,'r','Linewidth', 1.5,'MarkerFaceColor','r');hold on;%Times New Roman Helvetica
ylabel('loss');
set(gca,'ycolor',[0 0 0]);
axis([0,150,0.1,2]);%座標範圍大小設定
yyaxis right;
plot (c,d,'Color', [0 114 189]/255,'Linewidth', 1.5,'MarkerFaceColor','r');hold on;%Times New Roman Helvetica
ylabel('learning rate');
set(gca,'ycolor',[0 0 0]);
axis([0,150,-0.0002,0.0052]);%座標範圍大小設定

 

xlabel('step');
set(gca,'FontSize',12,'Fontname', 'Helvetica');%字型字號大小設定
set(gcf,'unit','normalized','position',[0.1,0.1,0.4,0.5]);%圖窗位置大小設定
set(gca,'XTick',0:20:150);
title('Train Loss and Ir');
legend('loss','Ir');