Matlab论文插图绘制模板第122期—函数折线图(fplot)

编程入门 行业动态 更新时间:2024-10-25 06:22:34

Matlab论文<a href=https://www.elefans.com/category/jswz/34/1731172.html style=插图绘制模板第122期—函数折线图(fplot)"/>

Matlab论文插图绘制模板第122期—函数折线图(fplot)

本期分享的是函数折线图的绘制模板。​

所谓函数折线图,就是将自定义线函数进行可视化表达​。

先来看一下成品效果:

特别提示:本期内容『数据+代码』已上传资源群中,加群的朋友请自行下载。有需要的朋友可以关注同名公号【阿昆的科研日常】,后台回复关键词【绘图桶】查看加入方式


模板中最关键的部分内容

1. 数据准备

此部分主要是构造函数

% 构造函数fun1 = @(x) sin(1.1*x-pi/5);fun2 = @(x) sin(1.1*x);fun3 = @(x) sin(1.1*x+pi/5);fun4 = @(x) sin(1.1*x+2*pi/5);

2. 颜色定义

作图不配色就好比做菜不放盐,总让人感觉少些味道。

但颜色搭配比较考验个人审美,需要多加尝试。

这里直接使用TheColor配色工具中的SCI权威配色库

C = TheColor('sci',1796);

3. 函数折线图绘制

利用‘fplot’命令,绘制初始函数折线图

p1 = fplot(fun1,[-5 5],'LineStyle','-','Marker','v','LineWidth',2,'MarkerFaceColor',C(1,1:3),'Color',C(1,1:3));hold onp2 = fplot(fun2,[-5 5],'LineStyle','-','Marker','o','LineWidth',2,'MarkerFaceColor',C(2,1:3),'Color',C(2,1:3));p3 = fplot(fun3,[-5 5],'LineStyle','-','Marker','^','LineWidth',2,'MarkerFaceColor',C(3,1:3),'Color',C(3,1:3));p4 = fplot(fun4,[-5 5],'LineStyle','-','Marker','s','LineWidth',2,'MarkerFaceColor',C(4,1:3),'Color',C(4,1:3));hTitle = title('Fplot Plot');hXLabel = xlabel('XAxis');hYLabel = ylabel('YAxis');

4. 细节优化

为了插图的美观,对图形细节等进行美化

% 坐标区属性调整set(gca, 'Box', 'off', ...                                % 边框         'LineWidth', 1,...                               % 线宽         'XGrid', 'off', 'YGrid', 'on', ...               % 网格         'TickDir', 'out', 'TickLength', [.01 .01], ...   % 刻度         'XMinorTick', 'off', 'YMinorTick', 'off', ...    % 小刻度         'XColor', [.1 .1 .1],  'YColor', [.1 .1 .1])     % 坐标轴颜色set(gca, 'XLim',[-5.2 5.2],...         'YLim',[-1.1 1.1])% LegendhLegend = legend([p1,p2,p3,p4], ...                 'Samp1', 'Samp2','Samp3','Samp4', ...                 'Location', 'northeast');% Legend位置微调 P = hLegend.Position;hLegend.Position = P + [0.00 0.01 0 0];% 字体和字号set(gca, 'FontName', 'Arial', 'FontSize', 10)set([hLegend, hXLabel, hYLabel], 'FontSize', 11, 'FontName', 'Arial')set(hTitle, 'FontSize', 12, 'FontWeight' , 'bold')% 背景颜色set(gcf,'Color',[1 1 1])% 添加上、右框线xc = get(gca,'XColor');yc = get(gca,'YColor');unit = get(gca,'units');ax = axes( 'Units', unit,...           'Position',get(gca,'Position'),...           'XAxisLocation','top',...           'YAxisLocation','right',...           'Color','none',...           'XColor',xc,...           'YColor',yc);set(ax, 'linewidth',1,...        'XTick', [],...        'YTick', []);

设置完毕后,以期刊所需分辨率、格式输出图片。

%% 图片输出figW = figureWidth;figH = figureHeight;set(figureHandle,'PaperUnits',figureUnits);set(figureHandle,'PaperPosition',[0 0 figW figH]);fileout = 'test';print(figureHandle,[fileout,'.png'],'-r300','-dpng');

以上。

更多推荐

Matlab论文插图绘制模板第122期—函数折线图(fplot)

本文发布于:2023-12-04 11:30:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1660771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插图   函数   模板   论文   折线图

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!