MATLAB | 绘制博士学位的图解指南
Posted slandarer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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','VerticalAlignmentDBA教育丨这下秒懂了,工商管理博士(DBA)学位图解指南