6

I've been using LaTeX for a long time, however I have never been into the TiKZ class, I need to create the following drawing,

enter image description here

I only have to draw the boundary of the mesh and the dots (not the data written around). I've been reading the package manual but I have only been able to paint the boundary, however I have no idea on how to paint the nodes dots.

I know the process of drawing the dots will be repetitive, so if you could explain me how to paint one or a couple, I think I could do the rest by myself.

P.S: If you know how to paint the arrows at both sides, it'd be helpful that you explain it to me because I didn't get to do it, even though that part is not essential.

Thanks so much for help on beforehand.

  • For both dots and arrows look at the iterators in the TikZ manual. – ajeh Nov 27 '14 at 20:37
  • 1
    Welcome to TeX.sx! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – Werner Nov 27 '14 at 20:47
  • I have never been into the TiKZ class Is there even a TiKz class offered anywhere? I've never even seen a Latex class offered, at least in the US. So this makes it even less likely there is a Tikz class. But it is a good idea. We really need a Latex university, where one can get a PhD in Latex if needed. – Nasser Nov 27 '14 at 20:57
  • With class I wanted to mean package. In some programming languages, classes are defined that way. I was not tryinh to confuse you. @nasser – user3780731 Nov 27 '14 at 21:38
  • @Werner I don't want you to make me this drawing. If you read my question I just need to know the code for painting that kind of dot since I did not find it on the manual. The rest, is already done. I also know about iterations, so I just want someone to help me with drawing a single dot. Am I even asking for the whole picture? No. – user3780731 Nov 27 '14 at 21:40
6

This is another attempt where each dot has an internal label (of Euclidean coordinate system) and utilize the labels as references to draw lines via foreach loop, some relative coordinates are used. As for labels around the diagram, only a few of them are shown, same techniques are applicable though.

enter image description here

Code

\documentclass[border=10pt]{standalone}
%\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,16}
\foreach \j in {1,...,11}
\node[shape=circle,inner sep=2pt,fill=cyan] at (\i,\j){}; % use no fill and external label {\tiny$\i\j$} to show labels

% draw lines
\foreach \j in {6,...,11}{
\draw[thick,->,>=stealth'] (-1,\j)coordinate(ls\j){} --++(1,0)coordinate(le\j){};}
\draw[line width=2pt] (ls6)--(ls11); % left line start-start
\draw[line width=2pt,cyan] (le6)--(le11); % left line end-end

\foreach \j in {1,...,11}{
\draw[thick,->,>=stealth'] (17,\j)coordinate(rs\j){} --++(1,0)coordinate(re\j){};}
\draw[line width=2pt] (rs1)--(rs11);      % right line start-start
\draw[line width=2pt,cyan] (re1)--(re11); % right line end-end
\draw[line width=2pt] ([yshift=0.5cm]ls11)--([yshift=0.5cm]re11);  % left line start to right line end
\draw[line width=2pt] ([yshift=-0.5cm]ls6)--([yshift=-0.5cm]6,6)node(a){};  % left line start to right line end
\draw[line width=2pt] ([yshift=-0.5cm]11,1)node(b){}--([yshift=-0.5cm]re1); % left line start to right line end
\draw[line width=2pt] ([yshift=-0.5cm]6,6)--([yshift=-0.5cm]11,1);  % left

% remove the lower left corner
\path[fill=white] (0,0.5)--(0,5.3)--(6,5.3)--(10.7,0.5)--cycle;

% some labeling for demonstration only
\draw[line width=1pt,<->] (6,0.5)--(11,0.5) -- ++ (-3,0) arc(180:135:3);
\node[fill=white] at (8.3,1.5) {$45^{\circ}$};
\node[fill=white] at (1,5) {(1,6)};
\node[fill=white] at (3,5) {$y=1m$};
\node[fill=white] at (5,5) {(6,6)};
\draw[->] (1,1) -- (3,1)node[right](){$i$};
\draw[->] (1,1) -- (1,3)node[above](){$j$};
\end{tikzpicture}
\end{document}
  • You are welcome. Glad it helps. – Jesse Nov 29 '14 at 10:11
  • By the way, I see that you know a lot about TiKz, could you recommend me a good way to learn how to use it well? Thanks! @Jesse – user3780731 Nov 29 '14 at 10:19
  • I started learning tikz from finding summary notes (many of them) from internet to gain some basic skills, then practice a lot to familiar myself with it. Whenever I don't know how, I will search internet for an answer and that is how I found this site more than one year ago. In short, learning by practicing, IMHO. – Jesse Nov 29 '14 at 10:45
  • @user3780731 The manual is long but it is quite helpful. You can look up the bit you need and it includes lots of examples. When I don't know how to do something, that's where I start. – cfr Nov 29 '14 at 16:26
1

You can use \foreach for iterations.

The following code, draws 25 dots, 5 in rows and 5 in columns, in a square form. Then you can easily extend the code. Of course you need to read the tikz guide (find \foreach in the pdf). I think the tikz have the most comprehensive document among LaTeX packages.

\begin{tikzpicture}

\foreach \x in {0, 1, ..., 4}
 \foreach \y in {0, 1, ..., 4}
  \draw (\x, \y) node [circle, fill, color=blue, inner sep=1.5pt] {};

\end{tikzpicture}
  • Thanks too, this is what I was thinking iterating along the mesh. I was more interested in the drawing dots part. This helped a lot thanks! – user3780731 Nov 29 '14 at 9:59
0

Or you could just fill the shape with dots (which will be rendered faster than drawing circles iteratively):

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{patterns}
\begin{document}

  \begin{tikzpicture}
    \path [pattern=dots, pattern color=blue] (0,0) rectangle (5,2.5);
  \end{tikzpicture}

\end{document}

blue dots pattern

  • True! This was faster even though more points are plotted! I like that way though thanks!! – user3780731 Nov 29 '14 at 10:00

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.