我们如何绘制这样的图表:
和
答案1
Asymptote
只需几个简单的步骤即可轻松创建此类图表:
准备定义曲线和轮廓的点数组,例如:
// Left contour points
pair[] pa={
(134,37),
(193,47),
(196,82),
(150,111),
(90,117),
(33,98),
(9,73),
(7,57),
(29,48),
(80,49),
};
从准备好的点构建实际曲线(路径)并绘制它们(..cycle
在封闭轮廓的情况下添加):
guide ga=graph(pa,operator..)..cycle;
draw(ga,linePen);
准备标签及其坐标的数组TeX
,并在循环中绘制它们for
:
pair[] labelPos={
(71,76),
(232,103),
(406,71),
(446,110),
};
string[] labelTeX={
"$(X,T)$",
"$f:X\rightarrow Z$",
"$Z$",
"$(Y,T^\prime)$",
};
for(int i=0;i<labelTeX.length;++i){
label(labelTeX[i],labelPos[i]);
}
第二张图需要一个filldraw
命令来绘制填充区域。
完整来源diag.tex
在这里:
\documentclass{article}
\usepackage[inline]{asymptote}
\begin{document}
\begin{figure}
\begin{asy}
size(400);
import graph;
// Left contour points
pair[] pa={
(134,37),
(193,47),
(196,82),
(150,111),
(90,117),
(33,98),
(9,73),
(7,57),
(29,48),
(80,49),
};
// Right outer contour points
pair[] pb={
(453,25),
(469,41),
(483,58),
(494,84),
(485,112),
(462,132),
(441,138),
(422,146),
(411,149),
(389,147),
(357,140),
(280,100),
(268,86),
(261,74),
(267,65),
(277,57),
(291,38),
(307,17),
(337,8),
(401,7),
};
// Right inner contour points
pair[] pc={
(414,48),
(426,67),
(425,100),
(401,110),
(376,111),
(343,104),
(330,102),
(314,89),
(306,81),
(309,71),
(316,63),
(332,57),
(356,46),
(386,40),
};
// Arrow points
pair[] parrow={
(122,79),
(234,93),
(372,73),
};
pair[] labelPos={
(71,76),
(232,103),
(406,71),
(446,110),
};
string[] labelTeX={
"$(X,T)$",
"$f:X\rightarrow Z$",
"$Z$",
"$(Y,T^\prime)$",
};
defaultpen(fontsize(10pt));
pen linePen=darkblue+1.2bp;
for(int i=0;i<labelTeX.length;++i){
label(labelTeX[i],labelPos[i]);
}
guide ga=graph(pa,operator..)..cycle;
guide gb=graph(pb,operator..)..cycle;
guide gc=graph(pc,operator..)..cycle;
guide garrow=graph(parrow,operator..);
draw(ga,linePen);
draw(gb,linePen);
draw(gc,linePen);
draw(garrow,linePen,Arrows(HookHead,size=3));
\end{asy}
\\[20pt]
\begin{asy}
size(400);
import graph;
// Outer contour points
pair[] pb={
(283,46),
(296,60),
(301,94),
(295,134),
(284,171),
(258,198),
(233,205),
(206,215),
(189,220),
(164,217),
(116,201),
(76,176),
(35,144),
(14,120),
(6,107),
(4,85),
(6,68),
(14,47),
(38,49),
(70,47),
(102,41),
(134,35),
(170,29),
(203,24),
(237,26),
(263,35),
};
// Inner contour points
pair[] pc={
(163,107),
(181,111),
(199,121),
(209,134),
(212,151),
(201,172),
(181,179),
(159,180),
(126,172),
(97,162),
(78,145),
(65,133),
(65,124),
(74,119),
(82,120),
(99,120),
(119,117),
(142,115),
};
// span points
pair[] pspan={
(476,120),
(604,120),
};
// Arrow points
pair[] parrow1={
(197,77),
(324,149),
pspan[0]
};
pair[] parrow2={
(189,153),
(218,169),
(266,192),
(327,202),
(395,202),
(433,198),
(466,192),
(508,182),
(541,168),
(568,151),
pspan[0]*(1-0.95)+pspan[1]*0.95
};
pair[] labelPos={
(65,77),
(192,62),
(374,115),
(375,220),
(143,143),
};
string[] labelTeX={
"$(X,T)$",
"$a$",
"$f(a)=0$",
"$f(F)=\{1\}$",
"$F$",
};
defaultpen(fontsize(10pt));
for(int i=0;i<labelTeX.length;++i){
label(labelTeX[i],labelPos[i]);
}
guide gb=graph(pb,operator..)..cycle;
guide gc=graph(pc,operator..)..cycle;
guide garrow1=graph(parrow1,operator..);
guide garrow2=graph(parrow2,operator..);
pen fillPen=orange;
pen linePen=darkblue+1.2bp;
draw(gb,linePen);
filldraw(gc,fillPen,linePen);
real tickW=3bp;
draw(pspan[0]--pspan[1],linePen);
draw((pspan[0]-(0,tickW))--(pspan[0]+(0,tickW)),linePen);
draw((pspan[1]-(0,tickW))--(pspan[1]+(0,tickW)),linePen);
label("$0$",pspan[0]-(0,tickW),S);
label("$1$",pspan[1]-(0,tickW),S);
draw(garrow1,linePen,Arrow(HookHead,size=3));
filldraw(circle(parrow1[0],3bp),linePen);
draw(garrow2,linePen,Arrow(HookHead,size=3));
\end{asy}
\end{figure}
\end{document}
为了处理它latexmk
,请创建文件latexmkrc
:
sub asy {return system("asy '$_[0]'");}
add_cus_dep("asy","eps",0,"asy");
add_cus_dep("asy","pdf",0,"asy");
add_cus_dep("asy","tex",0,"asy");
然后运行latexmk -pdf diag.tex
。