Matlab绘图案例,设置图片大小,坐标轴比例为黄金比

Matlab 复制代码
% DICNdemo


if 1
    close all
    JNR_vec_M=-15:20;
    AccMY=[0.673571428571429;0.681046335211165;0.694722162918878;0.710227376209125;0.732289789123783;...
        0.753134610962165;0.772665550701182;0.798340543597937;0.823451665011233;0.854186040239566;...
        0.882958348012429;0.913480599983476;0.936183082804026;0.949402479333189;0.966463510166192;...
        0.977788018433180;0.986451612903226;0.990322580645161;0.994193548387097;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1];
    Acc_CL=[0.464285714285714;0.481768416768417;0.531267399267399;0.573474969474970;0.621887667887668;...
        0.675471306471307;0.719941391941392;0.762638583638584;0.796471306471307;0.822769230769231;...
        0.851463980463981;0.886249084249084;0.914090354090354;0.945192918192918;0.975113553113553;...
        0.992000000000000;0.996000000000000;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1];
    ACC_CNN=[0.580000000000000;0.586530612244898;0.597850340136054;0.609605442176871; 0.623537414965986; ...
        0.638049886621315;0.653723356009070;0.673315192743764;0.699873015873016;0.734557823129252;...
        0.773886621315193;0.814521541950114;0.849351473922903;0.887038548752835;0.917405895691610;...
        0.940662131519274;0.959129251700680;0.976000000000000;0.980000000000000;0.984000000000000;...
        0.988000000000000;0.992000000000000;0.996000000000000;1;1;1;1;1;1;1;1;1;1;1;1;1];
    
    % 颜色值
    thisR=[236 31 36]/255;
    thisG=[12 153 71]/255;
    thisB=[57 82 164]/255;
    thisK=[0.05 0.05 0.05];
    thisZi=[126 46 141]/255;
    thisZi_F=[184  82 159]/255;
    thisY=[236 177 31]/255;
    thisJu=[216 82  24]/255;
    thisQ=[41 255 255]/255;
    thisHui=[127 127 127]/255/1.5;
    OrigB=[0  0 1];
    OrigR=[1  0 0];
    
    % 绘图
    figure
    p1=100;
    p2=100;
    d1=420;
    d2=d1*0.618;
    zonghengBi=0.73;
    d1_add=d1*1.3;
    d2_add=d1_add*zonghengBi;
    set(gcf,'position',[p1,p2,d1_add,d2_add]);
    set(gca,'Position',[80/d1_add   92/d2_add   d1/d1_add   (d2/d2_add)]);  %/zonghengBi
    
    idxP1=sort([1:2:20 20 22 25:3:36 ]);
    L1=plot(JNR_vec_M,AccMY,'-*','color',thisR,'LineWidth',1.5,'MarkerSize',7,'MarkerIndices',idxP1,'MarkerFaceColor','w');
    hold on
    idxP2=sort([1:2:21  23 26:3:36 ]);
    L2=plot(JNR_vec_M,Acc_CL,'-o','color',thisK,'LineWidth',1.5,'MarkerSize',5,'MarkerIndices',idxP2,'MarkerFaceColor','w');
    hold on
    idxP3=sort([1:2:21 24:3:36 ]);
    L3=plot(JNR_vec_M,ACC_CNN,'-^','color',thisB,'LineWidth',1.5,'MarkerSize',5,'MarkerIndices',idxP3,'MarkerFaceColor','w');
    % 覆盖
    hold on
    plot(JNR_vec_M,AccMY,'*','color',thisR,'LineWidth',1.5,'MarkerSize',7,'MarkerIndices',idxP1,'MarkerFaceColor','w');
    hold on
    plot(JNR_vec_M,Acc_CL,'o','color',thisK,'LineWidth',1.5,'MarkerSize',5,'MarkerIndices',idxP2,'MarkerFaceColor','w');
    
    FontSize=14;
    %xlim([-15.5 15])  xlim([-12 25])
    ylim([0.5 1.01])
    set(gca,                                            'Fontname','Times New Roman','Fontsize',FontSize);
    ylabel('$P\rm{_c}$',          'interpreter','latex','Fontname','Times New Roman','FontSize',FontSize)
    xlabel({'$\rm{INR(dB)}$'},    'interpreter','latex','Fontname','Times New Roman','FontSize',FontSize);%'Century'
    %     set(gca,'TickLabelInterpreter','latex');
    %     set(gca,'XTick',[-5:5:25]);
    grid on
    g1=0.487903225806452;
    g2=0.250502008032129;
    g3=0.420023460410557;
    g4=0.181;
    
    posRec3=0.4;
    posRec4=0.8;
    
    lgd=legend([L1 L2 L3],{'$L_{\textit{\textbf{f}}\,}=8$,HL',...
        '$L_{\textit{\textbf{f}}\,}=6$',...
        '$L_{\textit{\textbf{f}}\,}=4$'});
    lgd=legend([L1 L2 L3],{'\fontname{Times New Roman}      = 8, XXX \fontname{宋体}算法法',...
        '\fontname{Times New Roman}      = 6, NNN \fontname{宋体}算法法 ',...
        '\fontname{Times New Roman}      = 4, LLL \fontname{宋体}算法法'});
    set(lgd,'Position',[g1,g2,g3,g4],'interpreter','tex','Fontname','Times New Roman','Fontsize',14,'NumColumns',1);
    pos_axis = get(gca,'Position');
    
    % 文本框
    textPosi=[
        0.5753  0.3626 0.05 0.06;
        0.5753  0.3032 0.05 0.06;
        0.5753  0.2457 0.05 0.06];
    for ti=1:3
        annotation('textbox',...
            textPosi(ti,:),...
            'VerticalAlignment','middle',...
            'String','$L_{ }$',...
            'Interpreter','latex',...
            'Margin',1,...
            'HorizontalAlignment','center',...
            'FontSize',14,...
            'FontName','Times New Roman',...
            'FontAngle','italic',...
            'FitBoxToText','off',...
            'EdgeColor','none',...
            'BackgroundColor','none');
    end
    
    symPosi=[
        0.599,0.3633 0.05 0.06;
        0.599 0.3038 0.05 0.06;
        0.599 0.2488 0.05 0.06];
    for ti=1:3
        annotation('textbox',...
            symPosi(ti,:),...
            'String',{'f'},...
            'FontWeight','bold',...
            'FontName','Times New Roman',...
            'FontAngle','italic',...
            'FitBoxToText','off',...
            'EdgeColor','none',...
            'BackgroundColor','none');
    end
    
    % 图片保存
    picName=sprintf('ImageForThesis/CH3_Pc_JNR_method.eps');
    set(gcf,'Units','Inches');
    % set(gcf,'Units','centimeters');
    pos = get(gcf,'Position');
    % set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3)-posRec3, pos(4)-posRec4])
    %saveas(gcf,picName,'psc2')
    
    picName=sprintf('ImageForThesis/CH3_Pc_JNR_method.pdf');
    set(gcf,'Units','Inches');
    pos = get(gcf,'Position');
    set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3)-posRec3, pos(4)-posRec4])
    %     print(gcf,picName,'-dpdf','-r0');
end
相关推荐
颜酱1 小时前
理解二叉树最近公共祖先(LCA):从基础到变种解析
javascript·后端·算法
中杯可乐多加冰1 小时前
OpenClaw到底能做什么?有什么用?先装这几个实用的Skills
人工智能
千寻girling1 小时前
一份不可多得的 《 Python 》语言教程
人工智能·后端·python
全栈老石3 小时前
拆解低代码引擎核心:元数据驱动的"万能表"架构
数据库·低代码
aircrushin3 小时前
从春晚看分布式实时协同算法与灵巧手工程实现
人工智能·机器人
恋猫de小郭3 小时前
Apple 的 ANE 被挖掘,AI 硬件公开,宣传的 38 TOPS 居然是"数字游戏"?
前端·人工智能·ios
银河系搭车客指南4 小时前
AI Agent 的失忆症:我是怎么给它装上"第二个大脑"的
人工智能
张拭心4 小时前
春节后,有些公司明确要求 AI 经验了
android·前端·人工智能
我的username4 小时前
极致简单的openclaw安装教程
人工智能
小锋java12344 小时前
【技术专题】嵌入模型与Chroma向量数据库 - Chroma 集合操作
人工智能