For one of my academic courses, i need to generate sample lattices and was wondering if there was any way to generalize the hard-coded points I am using. Instead of repeating -5.19,-3.46,-1.73,0,1.73,3.46,5.19
all the time, is there a way to define a macro or equivalent.
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=5.5in,compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,
xmin=-6, xmax=6,
ymin=-6,ymax=6,
xlabel = $x$,
ylabel = $y$]
\addplot [->, thick, red]
coordinates { (0,0) (sqrt(3),1)} node[above right,pos=1] {$v_1$};
\addplot [->, thick, blue]
coordinates { (0,0) (0,2)} node[above right,pos=1] {$v_2$};
\addplot+ [mark=none,black] table {
0.5 1
-0.5 1
-1 0
-0.5 -1
0.5 -1
1 0
0.5 1
};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x + 2};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x-2};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x-4};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x+4};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x-6};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x+6};
\addplot[only marks, mark=o, samples at={-5.19,-3.46,-1.73,0,1.73,3.46,5.19}]{-0.55*x};
\end{axis}
\end{tikzpicture}
\end{document}