clear ;clear all;
% ======================================================
%% 更改线图颜色:
% 预定义颜色:'b':蓝色(blue)'g':绿色(green)'r':红色(red)'c':青色(cyan)
% 'm':品红色(magenta)'y':黄色(yellow)'k':黑色(black)'w':白色(white)
% RGB颜色:'[R, G, B]':使用RGB值设置颜色,其中R、G、B是介于0和1之间的小数。
%% 线型:
% 实线: `'-'`:标准实线。
% 虚线: `'--'`:标准虚线。`':'`:点线。
% 点线: `'-.'`:组合虚线和点线。
% 点:`'.'`:小圆点。`'o'`:大圆点。`'s'`:正方形点。`'d'`:菱形点。`'^'`:上三角点。
% `'v'`:下三角点。`'<'`:左三角点。`'>'`:右三角点.`'p'`:五边形点。`'h'`:六边形点。
% 线和点的组合:`'x'`:叉号。`'+'`:加号。
% 特殊线型:
% `'none'`:无线型,用于隐藏线。
%% markerstyle = {'+', 'o', '*', '.', 'x', 's', 'd', '^', 'v', '<', '>'}; %标记符
%% 添加标题和轴标签
% 显示图例(可选)
% 设置坐标轴纵横比例相等(可选)
% axis equal;
%% 设置刻度
% data=load("par_for_IFEM.txt");% 导入数据
% set(gca, 'xTick', [0:1:10]);
% ax = gca; % current axes
% ax.XLim = [0 10];%刻度值范围
% ax.FontSize = 12;%刻度值字号大小
% ax.TickDir = 'in';%刻度指向
% ax.TickLength = [0.01 0.01];%刻度长短
% % set(gca,'XTickLabel',{'0','3','5','10','15','20','25','30'})
% % % % figure
x1=0:100:600;
f1_NDI=[0 -0.700270593 -2.644574023 -5.842842639 -9.979173742 -14.95354346 -19.80276989];
f1_iLRPIM_order2=[0 -0.000589270757013 -0.002402122312728 -0.005304367004923 -0.009181274752047 -0.014070326642686 -0.019802799663115]*1000;
f2_NDI=[0 -1.777685681 -6.636155729 -14.54528267 -24.82857516 -37.26354622 -49.74521061];
f2_iLRPIM_order2=[0 -0.001258193648681 -0.005264715352910 -0.011840493210262 -0.020764671814042 -0.031586670396982 -0.043343576276551]*1000;
a3=1089;
f3_NDI=[0 -3.086969614 -11.46705987 -25.10828602 -42.75282623 -63.9135691 -85.20542597];
f3_iLRPIM_order2=[0 -0.001900023185036 -0.008415102595842 -0.019537389381740 -0.034700306864436 -0.053664104097031 -0.075416152350676]*1000;
a4=1000;
f4_NDI=[0 -0.163892953 -0.617519819 -1.357862987 -2.320843914 -3.485985198 -4.666681505];
f4_iLRPIM_order2=[0 -0.000151242155332 -0.000617798230380 -0.001357749113819 -0.002316423596088 -0.003459228234335 -0.004721104089914]*1000;
%% color = {'r', 'g', 'b', 'c', 'm', 'y', 'k', 'w', 'r', 'g', 'b'}; %颜色
%% linestyle = {'-.', '-', '--', ':', '-.', '-', '--', ':', '-.', '-', '--'}; %线型
%% 使线图光滑
nx = 200;
x1_new = linspace(min(x1), max(x1), nx);
f1=f1_NDI;
f2=f1_iLRPIM_order2;
f1_new = interp1(x1, f1, x1_new, 'spline'); % 使用spline插值方法
f2_new = interp1(x1, f2, x1_new, 'spline'); % 使用spline插值方法
figure;
plot(x1_new,f1_new,'-k',x1_new,f2_new,'--b','LineWidth',4)
hold on
f1=f2_NDI;
f2=f2_iLRPIM_order2;
f1_new = interp1(x1, f1, x1_new, 'spline'); % 使用spline插值方法
f2_new = interp1(x1, f2, x1_new, 'spline'); % 使用spline插值方法
plot(x1_new,f1_new,'-k',x1_new,f2_new,'--b','LineWidth',4)
hold on
f1=f3_NDI;
f2=f3_iLRPIM_order2;
f1_new = interp1(x1, f1, x1_new, 'spline'); % 使用spline插值方法
f2_new = interp1(x1, f2, x1_new, 'spline'); % 使用spline插值方法
plot(x1_new,f1_new,'-k',x1_new,f2_new,'--b','LineWidth',4)
hold on
f1=f4_NDI;
f2=f4_iLRPIM_order2;
f1_new = interp1(x1, f1, x1_new, 'spline'); % 使用spline插值方法
f2_new = interp1(x1, f2, x1_new, 'spline'); % 使用spline插值方法
plot(x1_new,f1_new,'-k',x1_new,f2_new,'--b','LineWidth',4)
% [legh,objh] = legend('curve1','curve2','Orientation','vertical'); % handles to the legend and its objects
leg = legend('NDI','iLRPIM-4th','Orientation','vertical','Location','southwest'); % handles to the legend and its objects
ab=32;
leg.ItemTokenSize = [200,200];
leg.FontSize = ab;
leg.FontWeight = 'bold';
% leg.LineWidth=3;
xlabel('x-axes / mm');
ylabel('Transverse displacement / mm');
% set(gca, "FontWeight","bold",'FontSize',ab);
set(gca,'FontSize',ab);
ax = gca; % current axes
ax.YLim = [-90 10];%刻度值范围
set(ax,'XColor','black','LineWidth',4);
set(ax,'YColor','black','LineWidth',4);
% There would be two line objects each (4 in total) associated to each of the line objects in the original plot.This can be found by:
% find the handles in 'objh' that correspond to line objects
matlab 二维线图绘制
最新推荐文章于 2024-05-29 17:30:16 发布