3

Clipping everything outside the axis is doable in pgfplots, but drawing lattices has not been great for me there because \foreach doesn't quite work inside axis environment. The code I came up with is this:

\begin{tikzpicture}[scale=0.3]
\draw[->, thick] (-15,0)--(15,0);
\draw[->, thick] (0,-15)--(0,15);

%PLOT
\foreach \x in {-5,-4,...,5}
\foreach \y in {-4,-3,...,4}
\draw[fill] (3.7320754717*\x-\y,-\x+3.7320754717*\y) circle [radius=.15];

\end{tikzpicture}

which expectedly yields:

enter image description here

but I'd rather have this if possible:

enter image description here

I could draw huge white rectangles to cover the unwanted points, but that doesn't quite solve the problem, because the figure will occupy too much space.

Sorry if this is duplicate.

5

Welcome to TeX.SE!

Are you looking for the following result?

enter image description here

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}


\begin{document}
    \begin{tikzpicture}[scale=0.3]
\draw[->, thick] (-15,0)--(15,0);
\draw[->, thick] (0,-15)--(0,15);

%PLOT
\clip (-15,-15) rectangle (15,15);  % <----
\foreach \x in {-5,-4,...,5}
\foreach \y in {-4,-3,...,4}
\draw[fill] (3.7320754717*\x-\y,-\x+3.7320754717*\y) circle [radius=.15];
    \end{tikzpicture}
\end{document}
2
  • 1
    @CarLaTeX, ups, typing error. Correct is as you say in your comment. Corrected now. Thank you for point me to this error.
    – Zarko
    Sep 25 at 17:49
  • 1
    You're welcome!
    – CarLaTeX
    Sep 25 at 18:05

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.