1

I have been trying to reproduce this image in tex, but I'd like to create it using $A_1$ and $A_2$ coordinates, but \def is not working.

Could anybody tell me the best way to do it? enter image description here thanks!

EDIT 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}

In my code, most of the measures are direct functions of $A_1$ and $A_2$ coordinates. In the commented lines I tried to define the vectors, so I could use their coordinates as parameters for the illustration.

(I'm writing the document still, I know the color scheme is bad!)

  • 2
    Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Thruston Dec 7 '15 at 11:14
  • 1
    And to add a slightly more human comment, there are lots of ways you could go about drawing this, but if you are having specific problems with some code, why not show us what you;ve got so far? – Thruston Dec 7 '15 at 11:16
  • 2
    Can you show us the code you have tried so far? Coordinates in tikz are usually (A1) rather than $A1$ and set via the \coordinate command. – Andrew Swann Dec 7 '15 at 12:23
  • 1
    Why you don't just use \coordinate (A_1) at (0,0) ? – CroCo Dec 7 '15 at 12:45
  • 1
    @AndrewSwann, I post it. – Guilherme Thompson Dec 7 '15 at 12:59
2

One example making use of a few defined coordinates and the -|/|- operators for defining coordinates and drawing lines.

enter image description here

\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}
3

For comparison, here is a version of the chart in Metapost, where the two vectors are defined at the top, and everything else is positioned relative to them (which I think was the OP intention). Notes below.

enter image description here

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.

Notes

  • Plain MP defines z$ to be equivalent to (x$,y$), where $ is any valid suffix. So when you define z1 = (120,42), you create variables x1 and y1 which you can use independently.

  • The units are PostScript points, but you can use others if you prefer. So you could write z1 = (5cm,2cm), and so on.

  • Multiplication by a numeric constant is "implicit", so 3x1 means 3 * x1.

2

You could use \coordinate inside the Tikz picture. For example,

\coordinate (O)   at (0,0);
\coordinate (A_1) at (3,4);
\draw[->, thick]  (O) -- ++ (A_1) node[below right] {$A_{1}$};
  • How could I use this same form to add the value marker in the axis? – Guilherme Thompson Dec 7 '15 at 12:49
  • 1
    I've made an edit but I think i was wrong so rolled back. sorry for that – percusse Dec 7 '15 at 12:51
  • @GuilhermeThompson, I don't understand your question. Do you want to show the actual values rather than the symbols? – CroCo Dec 7 '15 at 12:55
  • @percusse, no worries. – CroCo Dec 7 '15 at 12:56
  • In this line, for instance, \draw[shift={(0,4)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$A_{1,1}$};. How could I retrieve the values of A_1 to insert the marker into the axis? – Guilherme Thompson Dec 7 '15 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.