4

I don't know how to plot diagram like a "#", anyone could give some tips?

Thank you! enter image description here

2
  • Welcome to TeX.SX! Are those lines supposed to be bent or straight? Also, what have you tried so far?
    – siracusa
    Nov 11, 2018 at 2:04
  • I try the straight line through tikzcd, if I succeed I will paste my code.
    – lumw
    Nov 11, 2018 at 2:14

2 Answers 2

12

Welcome to TeX.SE! Can one draw such a graph? Sure. Are people here willing to do that for you? Well this will depend on their mood and also how new you are. Believe me, it is much more fun to do it on your own. Note also that there are 3d packages and nonlinear transformations etc. which can do a much better job if you have a concrete scenario and want more than just a cartoon.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{intersections}
\def\ldarray{{"i","i+1"}}
\def\luarray{{"k","k+\mu","k+1"}}
\begin{document}
\begin{tikzpicture}
\foreach \X in {1,2,3}
{\draw[name path global=hor-\X-0] (0.1*\X,2*\X) to[bend left=12] ++ (5,1);}
\foreach \X in {1,2}
{\draw[name path global=vert-\X-0] (2*\X-0.5,1+0.1*\X) to[bend left=15] ++ (0.3,7);}
\foreach \X [count=\XX starting from 0] in {1,2,3}
{\foreach \Y [count=\YY starting from 0] in {1,2}
{\pgfmathsetmacro{\ld}{\ldarray[\YY]}
\pgfmathsetmacro{\lu}{\luarray[\XX]}
\path[name intersections={of=hor-\X-0 and vert-\Y-0,by=p\X\Y}] (p\X\Y)
node[circle,fill,inner sep=2pt,label=below right:$g_{\ld}^{\lu}$]{};}}
\end{tikzpicture}
\end{document}

enter image description here

2
  • thank you very much. Follow your sample, i solve the problem.
    – lumw
    Nov 11, 2018 at 2:33
  • @Ben You're welcome. I actually simplified the code quite a bit by getting rid of all the \ifnum stuff ...
    – user121799
    Nov 11, 2018 at 2:41
7

Follow marmot's sample,

Notice \usetikzlibrary{intersections} and in the following code, define $Y= {1,2}$ is the Horizontal line, and $X={1,2,3}$ is the vert...

\begin{center}
\begin{tikzpicture}
\foreach \X in {1,2,3}
{\draw[name path global=hor-\X-0] (0.1*\X,2*\X) to[bend left=12] ++ (5,1);}
\foreach \X in {1,2}
{\draw[name path global=vert-\X-0] (2*\X-0.5,1+0.1*\X) to[bend left=15] ++ (0.3,7);}
\foreach \X in {1,2,3}
{\foreach \Y in {1,2}
    {\ifnum\Y=1
        \def\ly{i}
        \else
        \def\ly{i+1}
        \fi
        \ifnum\X=1
        \def\ld{k} 
        \else
        \ifnum\X=2
        \def\ld{k+\mu}
        \else
        \def\ld{k+1}
        \fi
        \fi
        \path[name intersections={of=hor-\X-0 and vert-\Y-0,by=p\X\Y}] (p\X\Y)
        node[circle,fill,inner sep=2pt,label=below right:$g_{\ly}^{\ld}$]{};}}
\end{tikzpicture}
\end{center}

enter image description here

You must log in to answer this question.

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