• MATLAB | 绘制博士学位的图解指南


    本文图解复刻自Matt Might的《博士学位的图解指南》一文,相关信息如下:

    • 作品名称 : The Illustrated Guide to a Ph.D.
    • 作者 : Matt Might
    • 作者主页 : http://matt.might.net/
    • 原作链接 : http://matt.might.net/articles/phd-school-in-pictures/

    知乎大佬白小鱼问我能不能用matlab画出《博士学位的图解指南》一文,我一瞅,这么有意思的东西咋能不水个文章呢hiahiahia,于是就有了这一篇。感谢大佬提供的想法。

    动图效果

    静态图效果

    完整代码

    function guide2phd
    % 原版图解相关信息:
    % 作品名称 : The Illustrated Guide to a Ph.D.
    % 作者     : Matt Might
    % 作者主页 : http://matt.might.net/
    % 原作链接 : http://matt.might.net/articles/phd-school-in-pictures/
    % ----------------------------------------------------------------
    % MATLAB代码复刻:
    % @author : slandarer
    % gzh    : slandarer随笔
    
    clc;clear
    % 坐标区域基础修饰
    ax=gca;hold on
    ax.XLim=[-1.1,1.1];
    ax.YLim=[-1,1.4];
    ax.DataAspectRatio=[1,1,1];
    ax.XColor='none';
    ax.YColor='none';
    
    % =========================================================================
    % 绘制各个图形对象
    Ct=linspace(0,2*pi,200);
    CL1=plot(cos(Ct),sin(Ct),'Color',[0,0,0],'LineWidth',1,'Visible','off');
    % -------------------------------------------------------------------------
    [EX1,EY1]=getEllipse([.5,.5]./sqrt(2),.5,.08,pi/4,200);
    EF1=fill(EX1,EY1,[241,63,32]./255,'EdgeColor','none','Visible','off');
    [EX2,EY2]=getEllipse([.3,.3]./sqrt(2),.3,.07,pi/4,200);
    EF2=fill(EX2,EY2,[242,95,79]./255,'EdgeColor','none','Visible','off');
    EF3=fill(cos(Ct).*.075+.255./sqrt(2),sin(Ct).*.075+.255./sqrt(2),...
        [244,139,128]./255,'EdgeColor','none','Visible','off');
    % -------------------------------------------------------------------------
    CF1=fill(cos(Ct).*.255,sin(Ct).*.255,[244,139,128]./255,'LineWidth',1,'EdgeColor','none','Visible','off');
    CF2=fill(cos(Ct).*.185,sin(Ct).*.185,[148,211,88]./255,'LineWidth',1,'EdgeColor','none','Visible','off');
    CF3=fill(cos(Ct).*.1,sin(Ct).*.1,[0,87,214]./255,'LineWidth',1,'EdgeColor','none','Visible','off');
    % -------------------------------------------------------------------------
    SL1=fill([-1,-1,1,1].*.15+1/sqrt(2),[-1,1,1,-1].*.15+1/sqrt(2),[0,0,0],...
        'FaceColor','none','LineWidth',1,'LineStyle',':','Visible','off');
    % -------------------------------------------------------------------------
    [EX4,EY4]=getEllipse([-1,-1],2.01,.32,pi/4,200);
    EF4=fill(EX4-.1,EY4-.4,[241,63,32]./255,'EdgeColor','none','Visible','off');
    EF5=fill((cos(pi/4)+cos(Ct)./55).*2-1-.1,(sin(pi/4)+sin(Ct)./55).*2-1-.4,...
        [241,63,32]./255,'EdgeColor','none','Visible','off');
    % -------------------------------------------------------------------------
    CL2=plot(cos(Ct).*2-1-.1,sin(Ct).*2-1-.4,'Color',[0,0,0],'LineWidth',4,'Visible','off');
    sep=pi/120;
    Ct1=linspace(pi/4+sep,2*pi+pi/4-sep,200);
    CX1=cos(Ct1);CY1=sin(Ct1);
    Ct2=linspace(-pi/4,pi/4+pi/2,200);
    CX2=cos(Ct2);CY2=sin(Ct2);
    CL3=plot([CX1,cos(pi/4)+CX2./55,CX1(1)].*2-1-.1,[CY1,sin(pi/4)+CY2./55,CY1(1)].*2-1-.4,...
        'LineWidth',4,'Color','k','Visible','off');
    % -------------------------------------------------------------------------
    QV1=quiver(0.4+.27,0.06,-.27,0,'off','filled','LineWidth',1.5,'Color',[0,0,0],'MaxHeadSize',.8,'Visible','off');
    TXT1=text(0.41+.3,0.06,'Ph.D.','FontSize',13,'FontWeight','bold','Visible','off');
    % -------------------------------------------------------------------------
    sep=pi/150;
    Ct1=linspace(pi/4+sep,2*pi+pi/4-sep,200);
    CX1=cos(Ct1);CY1=sin(Ct1);
    Ct2=linspace(-pi/4,pi/4+pi/2,200);
    CX2=cos(Ct2);CY2=sin(Ct2);
    CL4=plot([CX1,cos(pi/4)+CX2./60,CX1(1)],[CY1,sin(pi/4)+CY2./60,CY1(1)],...
        'LineWidth',1.2,'Color','k','Visible','off');
    % -------------------------------------------------------------------------
    Ct=linspace(0,pi/2,200);
    CF4=fill([cos(Ct),0].*2-1-.1,[sin(Ct),0].*2-1,[0,0,0],'EdgeColor','none','Visible','off');
    CF5=fill([cos(Ct),0].*1.2-1-.1,[sin(Ct),0].*1.2-1,[227,59,30]./255,'EdgeColor','none','Visible','off');
    % -------------------------------------------------------------------------
    QV2=quiver(1/sqrt(2)+.04+.07,1/sqrt(2)+.01,-.07,0,'off','filled',...
        'LineWidth',.5,'Color',[0,0,0],'MaxHeadSize',.9,'Visible','off');
    TXT2=text(1/sqrt(2)+.04+.07,1/sqrt(2)+.01,'Ph.D.','FontSize',6,'Visible','off');
    % =========================================================================
    % 动画制作
    TITLE=text(-1.08,1.37,{'Imagine a circle that contains','all of human knowledge:'},...
        'FontSize',13,'FontName','Cambria','VerticalAlignment','cap');
    CL1.Visible='on';
    DelayTime=2;
    F=getframe(ax);
    [imind,cm]=rgb2ind(F.cdata,256);
    imwrite(imind,cm,'PHD.gif','gif','Loopcount',inf,'DelayTime',DelayTime);
    
    pause(2)
    TITLE.String={'By the time you finish elementary school,','you know a little:'};
    CF3.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String={'By the time you finish high school,','you know a bit more:'};
    CF2.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String={"With a bachelor's degree,",'you gain a specialty:'};
    CF1.Visible='on';
    EF3.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="A master's degree deepens that specialty:";
    EF2.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String={"Reading research papers takes you to",'the edge of human knowledge:'};
    EF1.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="Once you're at the boundary, you focus:";
    SL1.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="You push at the boundary for a few years:";
    CL1.Visible='off';
    CF1.Visible='off';
    CF2.Visible='off';
    CF3.Visible='off';
    EF1.Visible='off';
    EF2.Visible='off';
    EF3.Visible='off';
    SL1.Visible='off';
    CL2.Visible='on';
    EF4.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="Until one day, the boundary gives way:";
    CL2.Visible='off';
    CL3.Visible='on';
    EF5.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String={"And, that dent you've made",'is called a Ph.D.:'};
    QV1.Visible='on';
    TXT1.Visible='on';
    addFrame(ax,DelayTime)
    
    
    pause(2)
    TITLE.String={"Of course," ,'the world looks different to you now:'};
    EF4.Visible='off';
    CL3.Visible='off';
    EF5.Visible='off';
    QV1.Visible='off';
    TXT1.Visible='off';
    CF4.Visible='on';
    CF5.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="So, don't forget the bigger picture:";
    CF4.Visible='off';
    CF5.Visible='off';
    CL4.Visible='on';
    QV2.Visible='on';
    TXT2.Visible='on';
    addFrame(ax,DelayTime)
    
    pause(2)
    TITLE.String="Keep pushing.";
    CL4.Visible='off';
    QV2.Visible='off';
    TXT2.Visible='off';
    addFrame(ax,DelayTime)
    % =========================================================================
    % 椭圆数据点生成函数
        function [X,Y]=getEllipse(Mu,XR,YR,theta,pntNum)
            % Mu     | 中心点
            % XR,YR  | 旋转前X,Y半轴长度
            % theta  | 旋转角度
            % pntNum | 生成数据点个数
            tList=linspace(0,2*pi,pntNum);
            X=cos(tList).*XR;
            Y=sin(tList).*YR;
            rotateMat=[cos(theta),-sin(theta);sin(theta),cos(theta)];
            XY=rotateMat*[X;Y]+Mu(:);
            X=XY(1,:);Y=XY(2,:);
        end
    
        function addFrame(ax,DelayTime)
            tF=getframe(ax);
            [timind,tcm]=rgb2ind(tF.cdata,256);
            imwrite(timind,tcm,'PHD.gif','gif','WriteMode','append','DelayTime',DelayTime);
        end
    end
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187

    再次注

    本文图解复刻自Matt Might的《博士学位的图解指南》一文,相关信息如下:

    • 作品名称 : The Illustrated Guide to a Ph.D.
    • 作者 : Matt Might
    • 作者主页 : http://matt.might.net/
    • 原作链接 : http://matt.might.net/articles/phd-school-in-pictures/
  • 相关阅读:
    Flutter中GetX系列七--依赖注入(put,lazyPut,putAsync)、Binding(统一初始化)
    欧拉闪电猫完成国内首次电动车高速螺旋翻滚跌落挑战
    ​cannot import name ‘container_abcs’ from ‘torch._six’​
    C++笔记打卡第23天(STL常用算法)
    FlinkSQL 之乱序问题
    Integritee通过XCM集成至Moonriver,为其生态系统带来企业级隐私解决方案
    QT职工工资管理系统
    OpenCV之VideoCapture
    如何比较分子的极性?
    CCF CSP认证 历年题目自练Day31
  • 原文地址:https://blog.csdn.net/slandarer/article/details/126822219