编辑1

编辑1

我一直试图在 tex 中重现此图像,但我想使用 $A_1​​$ 和 $A_2$ 坐标来创建它,但 \def 不起作用。

有人能告诉我最好的方法吗? 在此处输入图片描述 谢谢!

编辑1

\begin{figure}[h]
\centering  \begin{tikzpicture}
    \draw [<->] (0,10) node[left] {$m_{2}$} -- (0,0) node[below left] {$0$} -- (10,0) node[below] {$m_{1}$};

    %\def{\vA1}{(3,4)}
    %\def{\vA2}{(5,2)}

    \draw[->, thick]     (0,0) -- ++ (3,4) node[below right] {$A_{1}$};
    \draw[shift={(0,4)}] (2pt,0pt) -- (-2pt,0pt)    node[left]  {$A_{1,1}$};
    \draw[shift={(3,0)}] (0pt,2pt) -- (0pt,-2pt)    node[below] {$A_{2,1}$};

    \draw[->, thick]     (0,0) -- ++ (5,2) node[below right] {$A_{2}$};
    \draw[shift={(0,2)}] (2pt,0pt) -- (-2pt,0pt)    node[left]  {$A_{1,2}$};
    \draw[shift={(5,0)}] (0pt,2pt) -- (0pt,-2pt)    node[below] {$A_{1,2}$};

    \draw [-, blue, thick] (5,10) -- (5,4) -- (10,4);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, blue] at (9,9) {$\textbf{III}$};

    \draw [-, red, thick] (3,10) -- (3,4) -- (5,4) -- (5,2) -- (10,2);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, red] at (4,9) {$\textbf{I}$};
    \node[draw,circle,minimum size=1cm,inner sep=0pt, red] at (9,3) {$\textbf{II}$};

    \draw [-, green, thick] (0,10) -- (0,4) -- (3,4);
    \draw [-, green, thick] (10,0) -- (5,0) -- (5,2);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, green] at (1.5,9) {$\textbf{V}$};
    \node[draw,circle,minimum size=1cm,inner sep=0pt, green] at (9,1) {$\textbf{VI}$};

    \node[draw,circle,minimum size=1cm,inner sep=0pt, black] at (2.5,2) {$\textbf{IV}$};
\end{tikzpicture}
\caption{Limiting random walk diagram}\label{figlimitingrw}
\end{figure}

在我的代码中,大多数度量都是 $A_1​​$ 和 $A_2$ 坐标的直接函数。在注释行中,我尝试定义向量,以便可以使用它们的坐标作为插图的参数。

(我仍在写文档,我知道配色方案很糟糕!)

答案1

一个例子是利用一些定义的坐标和-|/|-运算符来定义坐标和绘制线条。

在此处输入图片描述

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\coordinate (A1) at (3,4);
\coordinate (A2) at (5,2);
\coordinate (O) at (0,0);
\coordinate (topleft) at (0,10);
\coordinate (botright) at (10,0);

    \draw [<->] (topleft) node[left] {$m_{2}$} -- (O) node[below left] {$0$} -- (botright) node[below] {$m_{1}$};

    \draw[->, thick]     (O) -- (A1) node[below right] {$A_{1}$};
    \draw[shift={(topleft|-A1)}] (2pt,0pt) -- (-2pt,0pt)    node[left]  {$A_{1,1}$};
    \draw[shift={(botright-|A1)}] (0pt,2pt) -- (0pt,-2pt)    node[below] {$A_{2,1}$};

    \draw[->, thick]     (O) -- (A2) node[below right] {$A_{2}$};
    \draw[shift={(A2-|topleft)}] (2pt,0pt) -- (-2pt,0pt)    node[left]  {$A_{1,2}$};
    \draw[shift={(A2|-botright)}] (0pt,2pt) -- (0pt,-2pt)    node[below] {$A_{2,2}$};

    \draw [blue, thick] (A2|-topleft) |- (A1-|botright);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, blue] at (9,9) {$\textbf{III}$};

    \draw [red, thick] (A1|-topleft) |- (A2|-A1) |- (A2-|botright);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, red] at (4,9) {$\textbf{I}$};
    \node[draw,circle,minimum size=1cm,inner sep=0pt, red] at (9,3) {$\textbf{II}$};

    \draw [green, thick] (topleft) |- (A1);
    \draw [green, thick] (botright) -| (A2);
    \node[draw,circle,minimum size=1cm,inner sep=0pt, green] at (1.5,9) {$\textbf{V}$};
    \node[draw,circle,minimum size=1cm,inner sep=0pt, green] at (9,1) {$\textbf{VI}$};
    \node[draw,circle,minimum size=1cm,inner sep=0pt, black] at (2.5,2) {$\textbf{IV}$};
\end{tikzpicture}

\end{document}

答案2

为了进行比较,以下是元帖子,其中两个向量在顶部定义,其他所有内容都相对于它们定位(我认为这是 OP 的意图)。注释如下。

在此处输入图片描述

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

z1 = (120,42);
z2 = ( 60,84);

path xx, yy;
xx = origin -- (3x1,0);
yy = origin -- (0,3y2);

drawoptions(withcolor .5 white);
draw xx;
draw yy;

drawoptions(withcolor .7 white);
draw xx shifted (0,y1) cutafter  yy shifted (x1,0) dashed withdots scaled 1/2;
draw xx shifted (0,y1) cutbefore yy shifted (x1,0);
draw xx shifted (0,y2);

draw yy shifted (x1,0);
draw yy shifted (x2,0) cutafter  xx shifted (0,y2) dashed withdots scaled 1/2;
draw yy shifted (x2,0) cutbefore xx shifted (0,y2);

drawoptions();
path a[];
a1 = origin -- z1;
a2 = origin -- z2;
drawarrow a1;
drawarrow a2;

draw btex $A_1$ etex shifted 4 up 
                     rotated angle direction 0.6 of a1 
                     shifted point 0.6 of a1;

draw btex $A_2$ etex shifted 4 up
                     rotated angle direction 0.6 of a2 
                     shifted point 0.6 of a2;

label.bot(btex $A_{1,1}$ etex, (x1,0));
label.bot(btex $A_{2,1}$ etex, (x2,0));
label.bot(btex $m_1$ etex, point 1 of xx);
label.lft(btex $A_{1,2}$ etex, (0,y1));
label.lft(btex $A_{2,2}$ etex, (0,y2));
label.lft(btex $m_2$ etex, point 1 of yy);

vardef do_region_label(expr s, p) = 
   draw superellipse(8 right, 6 up, 8 left, 6 down, 0.82) shifted p withcolor .67 blue;
   label(s,p) withcolor .67 blue;
enddef;

do_region_label("I",  ((x1+x2)/2, 2y2));
do_region_label("II", (2x1, (y1+y2)/2));
do_region_label("III",(2x1,2y2));
do_region_label("IV", 0.5[z1,z2]);
do_region_label("V",  (x2/2, 2y2));
do_region_label("VI", (2x1, y1/2));

endfig;
end.

笔记

  • 普通 MP 定义z$为等同于(x$,y$),其中$是任何有效后缀。因此,当您定义 时,您将创建可以独立使用的z1 = (120,42)变量x1和。y1

  • 单位是 PostScript 点,但如果您愿意,也可以使用其他单位。因此,您可以写成z1 = (5cm,2cm),等等。

  • 与数值常数相乘是“隐式的”,因此3x1意味着3 * x1

答案3

你可以\coordinate在 Tikz 图片中使用。例如,

\coordinate (O)   at (0,0);
\coordinate (A_1) at (3,4);
\draw[->, thick]  (O) -- ++ (A_1) node[below right] {$A_{1}$};

相关内容