学术资讯 » 学界研圈

  • 首 页
  • 期刊选题
  • 期刊点评
  • 期刊大全
  • 学人博客
  • 编辑征稿
  • 投稿选刊
  • 投稿群聊
  • 学术会议
  • 万维读书
  • SCI/E期刊
  • SSCI期刊
  • AHCI期刊
  • Matlab论文插图绘制模板第114期—带图形标记的图

    阅读: 2023/9/19 9:20:24

    之前的文章中,分享了Matlab带线标记的图:

    带阴影标记的图:

    带箭头标记的图:

    进一步,分享一下带图形标记的图,先来看一下成品效果:

    模板中最关键的部分内容:

    1. 数据准备

    此部分主要是读取原始数据。

    %% 数据准备

    data = [2 4 6 7 8 7 5 2];

    2. 颜色定义

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

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

    这里直接使用TheColor配色工具中的XKCD配色库:

    C = TheColor('xkcd',[572 298 693]);

    C1 = C(1,:);

    C2 = C(2,:);

    C0 = C(3,:);

    3. 带图形标记的图绘制

    通过调用‘annotation’命令,绘制初始带图形标记的图。

    st = stem(data,...

    'MarkerEdgeColor','k',... % 符号轮廓颜色

    'MarkerFaceColor',C0,... % 符号填充颜色

    'Marker','o',... % 符号类型

    'MarkerSize',10,... % 符号尺寸

    'LineWidth',1.5,... % 线宽

    'LineStyle','-',... % 线型

    'Color','k'); % 线的颜色

    axis([0 9 0 9])

    annotation('rectangle',[.32 .6 .2 .2],'Color',C1,'LineWidth',2)

    annotation('ellipse',[.68 .51 .11 .1],'Color',C2,'LineWidth',2)

    hTitle = title('Chart with Shape Label');

    hXLabel = xlabel('x');

    hYLabel = ylabel('y');

    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, 'FontName', 'Arial', 'FontSize', 10)

    set([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');

    以上。

    转自:“阿昆的科研日常”微信公众号

    如有侵权,请联系本站删除!


    浏览(217)
    点赞(0)
    收藏(0)
  • 上一篇:Matlab论文插图绘制模板第113期—带箭头标记的图

    下一篇:临床科研 | 上海交大章雪晴研究员团队再发《ACS NANO》:通过靶向mRNA纳米药物调节斑块炎症以治疗动脉粥样硬化

  • 首页

  • 文章

  • 期刊

  • 帮助

  • 我的

版权所有 Copyright@2023    备案号:豫ICP备2021036211号