3

enter image description here

Is there anyone who would like to help me draw this diagram in LaTeX? :-) I got help yesterday to draw the diagram, point and so on but I can't figure out how to draw the little boxes and the lines between points.

The code I got yesterday, and tried to edit...

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}   
\usetikzlibrary{decorations.pathreplacing}    
\begin{document}
\begin{tikzpicture}[>=stealth,font=\scriptsize,scale=1.8]

 % draw axis

 \draw[->](0,0)--(4,0)node[below]{1};
 \draw[->](0,0)--(0,4)node[left]{1};;

 % draw ticks 

 \foreach \i in {1,2,3}
 {\draw (\i,0.1)--(\i,-0.1)node[below]{$\frac{\i}{4}$};
 \draw (0.1,\i)--(-0.1,\i)node[left]{$\frac{\i}{4}$};
 }

 % draw bullets 

 \foreach \i in {0,...,3}
 {\foreach \j in {0,...,3}
 \node[fill=black,circle,inner sep=1pt] (\i-\j) at (\i,\j) {};
 }

 % label for bullets x and y

 \node[below right] at (2-1){$y_{j}$};
 \node[below] at (1-2){$x_{j}$}; 
 \draw(1-2)--(2,2);
 \draw(1-2)--(1,3);
 \draw[dashed](2-2)--(2,3);
 \draw[dashed](1-3)--(2,3);
 \draw(2-1)--(3,1);
 \draw(2-1)--(2,2);
 \draw[dashed](3-1)--(3,2);
 \draw[dashed](2-2)--(3,2);
 %\draw[decorate,decoration={brace,raise=3pt}](1-2)--(3-2)node[midway,above=4pt] {$|x-y|_\infty$};

 % dashed arrows

 \draw[dashed,<->](0.2,0)--(0.2,1);
 \draw[dashed,<->](0,0.2)--(1,0.2)node[midway,above,font=\tiny]{$2^{-m}=\frac{1}{2}$};

\end{tikzpicture} 
\end{document}
9
  • 2
    Do this for me question are really poor. Have you tried anything yet? Commented Mar 16, 2016 at 8:40
  • 4
    Most of that diagram was drawn for you in a different question, you could at the very least refer to that and specify what the trouble is here. Saying "I have this code which does the following, how can I extend it to do this other thing" is much better than just posting an image of what you need done. Commented Mar 16, 2016 at 8:56
  • 1
    Sorry, i'm new to this. I understand i should refer, i will do that next time.
    – Jeanett
    Commented Mar 16, 2016 at 8:57
  • 1
    You should add the code as a MWE of what you got already and revise your description and question...
    – Eric
    Commented Mar 16, 2016 at 9:23
  • 1
    I tried do add the code but i don't think i did it right because it doesn't show :/
    – Jeanett
    Commented Mar 16, 2016 at 9:53

2 Answers 2

4

To draw cross hatch box you can use \clip or \path[clip] inside a scope environment to limit showing diagonal lines inside a path which follows the edge of the two boxes.

\clip(1,3)--(2,3)--(2,2)--(3,2)--(3,1)--(2,1)--(2,2)--(1,2)--cycle;

Code

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}   
\usetikzlibrary{decorations.pathreplacing}    
\begin{document}
\begin{tikzpicture}[>=stealth,font=\scriptsize,scale=1.3]

 % draw axis

 \draw[->](0,0)--(6,0);
 \draw[->](0,0)--(0,6);

 % draw ticks 

 \draw (5,2pt)--(5,-2pt)node[below]{$1$};
 \draw (2pt,5)--(-2pt,5)node[left]{$1$};


 % draw bullets 

 \foreach \i in {0,...,4}
 {\foreach \j in {0,...,4}
 \node[fill=black,circle,inner sep=1pt]  at (\i,\j) {};
 }

 % label for bullets x and y

 \node[below] at (2,1){$y_{j}$};
 \node[below] at (1,2){$x_{j}$}; 
 \draw(1,2)--(2,2);
 \draw(1,2)--(1,3);
 \draw[dashed](2,2)--(2,3);
 \draw[dashed](1,3)--(2,3);
 \draw(2,1)--(3,1);
 \draw(2,1)--(2,2);
 \draw[dashed](3,1)--(3,2);
 \draw[dashed](2,2)--(3,2);

 % cross hatch boxes

 \begin{scope}
 \clip(1,3)--(2,3)--(2,2)--(3,2)--(3,1)--(2,1)--(2,2)--(1,2)--cycle;
 \foreach \sh in {-4,-3.9,...,4}
 {\draw[help lines] (1,1+\sh)--(3,3+\sh);}
 \end{scope}
 \draw[dashed](1.5,3)--(1.5,2)node[below,xshift=6pt]{$x_{j+1}$};
 \draw[dashed](1,2.5)--(2,2.5);
 \draw[dashed](2.5,2)--(2.5,1)node[below,xshift=6pt]{$y_{j+1}$};
 \draw[dashed](2,1.5)--(3,1.5);

 \node [fill=black,circle,inner sep=1pt,label=below:$x$ ]at(1.8,2.3){};
 \node [fill=black,circle,inner sep=1pt,label=below:$y$ ]at(2.2,1.8){};

 % dashed arrows

 \draw[dashed,<->](0.3,0)--(0.3,1);
 \draw[dashed,<->](0,0.3)--(1,0.3)node[pos=0.6,above,font=\tiny]{$2^{-j}$};

\end{tikzpicture} 
\end{document}

Output

enter image description here

2

A PSTricks solution:

\documentclass{article}

\usepackage{multido}
\usepackage{pstricks}

\begin{document}

\begin{pspicture}(-0.335,-0.415)(5.5,5.5) % frame parameters found manually
  \psline{->}(0,0)(5.5,0)
  \psline{->}(0,0)(0,5.5)
  \multido{\iA = 0+1}{5}{\multido{\iB = 0+1}{5}{\psdot(\iA,\iB)}}
  \psline(5,-0.1)(5,0.1)
  \uput[270](5,0){$1$}
  \psline(-0.1,5)(0.1,5)
  \uput[180](0,5){$1$}
 {\psset{linestyle = none, fillstyle = hlines}
  \psframe(1,2)(2,3)
  \psframe(2,1)(3,2)}
  \psline(1,3)(1,2)(2,2)(2,1)(3,1)
 {\psset{linestyle = dashed}
  \psline(1,3)(2,3)(2,2)(3,2)(3,1)
  \psline(1,2.5)(2,2.5)
  \psline(1.5,3)(1.5,2)
  \psline(2,1.5)(3,1.5)
  \psline(2.5,2)(2.5,1)
  \psline{<->}(0.4,0)(0.4,1)
  \psline{<->}(0,0.4)(1,0.4)}
 {\tiny
  \uput[45](0.4,0.4){$2^{-j}$}
  \uput[270](1,2){$x_{j}$}
  \uput[295](1.5,2){$x_{j + 1}$}
  \uput[270](2,1){$y_{j}$}
  \uput[295](2.5,1){$y_{j + 1}$}}
\end{pspicture}

\end{document}

output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .