如何在Matlab中绘制专业质量图? [英] How can I plot professional quality graphs in matlab?

查看:62
本文介绍了如何在Matlab中绘制专业质量图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从matlab生成的默认图形与我在书中看到的非常不同.例如,下面的图像在视觉上看起来令人愉悦.我可以更改matlab的默认设置来模仿这种图形样式吗?

解决方案

该问题将避免讲解OP上的图形最佳实践,而只是尝试按照要求回答该问题.我个人同意所提出的一些问题,但将其留给OP来寻找有关数据可视化和图形美感的资源.(根据记录,我不喜欢该图表.)

资源:

  1.  %感兴趣的函数%MATLAB 2018afh = @(x)a + a * sin(b * x)+ 1-exp(-b * x);gh = @(x)a +(a/b)* cos(c * x);a = 20;b = 0.3;c = 0.2;% 阴谋X =(0:.01:25)';图,坚持p(1)=情节(X,fh(X),'r-','DisplayName','Excitation')p(2)=情节(X,gh(X),'b-','DisplayName','Recovery')%图例(显示")%可选图例(由于我们要添加文本,因此在此省略)xlabel('X')ylabel('Y')标题(粒子位移")% 选项ha = gca;盒子上并网ylim([-80 100])set(ha,'GridLineStyle','-')%对点使用':'t(1)=文本(3.5,80,'激发')t(2)=文本(12,20,'recovery')对于k = 1:2p(k).LineWidth = 2.2;t(k).FontWeight ='粗体';t(k).FontSize = 12;t(k).FontName ='Arial';结尾 

    The default graphs produced from matlab are very different from what I see in books. For example the image below looks visually pleasing. Can I change default settings of matlab to mimic this graphing style?

    解决方案

    This question will refrain from lecturing the OP on best practices for graphics and simply attempt to answer the question as asked. I personally concur with a few of the concerns raised but leave it to the OP to seek out resources on data visualization and graphical aesthetics. (For the record, I'm not a fan of the chart.)

    Resources:

    1. The MATLAB Plot Gallery depicts a range of plots and adjustments that may help you. For high quality, professional looking graphs, scroll down to the Advanced Plots to see source code and the resulting figures.

    2. Graphical overview of the Types of MATLAB Plots available.

    3. You can also make a basic plot then use MATLAB's Plot Editor to customize the properties through the graphical interface. When done, click File-->Generate Code and you'll see one possible way to code that graph. This is helpful when you know how to do something through the interface but want to script it in the future.

    4. Examples with code for Publication Quality Plots with Matlab

    5. Mathworks blog on Making Pretty Graphs
    6. Another example on Creating high-quality graphics in MATLAB for papers and presentations

    I realize some of these links may eventually expire. Please feel free to comment if they do

    Example:
    I'm no expert. I learned everything in this answer from looking at the documentation, plot source code, and playing with the properties for the various plot components.

    % Functions of Interest                     % MATLAB 2018a
    fh=@(x) a + a*sin(b*x) + 1-exp(-b*x);
    gh=@(x) a + (a/b)*cos(c*x);
    a = 20;
    b = .3;
    c = .2;
    
    % Plot
    X = (0:.01:25)';
    figure, hold on
    p(1) = plot(X,fh(X),'r-','DisplayName','Excitation')
    p(2) = plot(X,gh(X),'b-','DisplayName','Recovery')
    % legend('show')    % Optional legend (omitted here since we're adding text)
    xlabel('X')
    ylabel('Y')
    title('Particle Displacement')
    
    % Options
    ha = gca;
    box on
    grid on
    ylim([-80 100])
    set(ha,'GridLineStyle','--')     % use ':' for dots
    t(1) = text(3.5,80,'excitation')
    t(2) = text(12,20,'recovery')
    for k = 1:2
        p(k).LineWidth = 2.2;
        t(k).FontWeight = 'bold';
        t(k).FontSize = 12;
        t(k).FontName = 'Arial';
    end
    

    这篇关于如何在Matlab中绘制专业质量图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆