I am trying to make the attached figure, which is meant to represent a cystal with and edge dislocation. The dots are the atoms and, of course, i would like to draw lines between them to represent the bonds. However i am struggling to do this.
What i did is (probably not the most optimal thing) since the lattice is irregular only on one half of the diagram, i split it in two parts and my code looks like this:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\draw [->,thick] (-3.5,0)--(3.5,0) node [above] {$x$};
\draw [->,thick] (0,-3.5) -- (0,3.5) node [right] {$y$};
\foreach \x in {-3,...,3.}{
\foreach \y in {0,...,3}{
\draw [fill=white] (\x,\y) circle [radius=0.05];
}
}
\foreach \d in {0.1,0.2,0.3} {
\foreach \x in {{-3+\d},{-2+\d+0.1},{-1+\d+0.2},{1-\d-0.2},{2-\d-0.1},{3-\d}} {
\draw [fill=white] (\x,{-10*\d}) circle [radius=0.05];}
}
\draw [dashed] (-0.15,-0.15) -- (0.15,-0.15) -- (0.15,3.15) -- (-0.15,3.15) -- cycle;
\end{tikzpicture}
\end{document}
But i simply don't know and can't find how to make the bonds in a loop. Is there a way i can do that, or a package that may help? Or do i just suffer and do the lines one by one and that's it?
A less important question, but now that i'm at it ill make it too, notice in the \foreach \d loop, i want to loop on \d and \y at the same time, one value of \d per value of \y, but i don't know how to do that, in this case i could just work with y=-10d but is there a way i can iterate in 2 variables from 2 different lists?
reaction for more information.