4

This is a related but very simple follow-up to a previous question, inspired by the comment of @marmot "Or do you want to use different grays for different planes?"

Here is what I have

enter image description here

This is a 8 x 8 x 8 cubic.

Suppose I like to have a 3 x 4 x 5 lattice with a darker lattice sitting at a new origin (2,2,2) of this 8 x 8 x 8 cubic. How should I do this? [It looks simple -- I just need to redraw another a 3 x 4 x 5 lattice sitting at a new origin (2,2,2).]

\begin{figure}[h!]
\centering
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[line width=0.01pt,black!20,xshift=5cm,scale=1.5]
 \foreach \X in {0,1,...,8}
 {\foreach \Y in {0,1,...,8}
 {\draw (\X/2,\Y/2,0) -- (\X/2,\Y/2,8/2);
 \draw (\X/2,0,\Y/2) -- (\X/2,8/2,\Y/2);
 \draw (0,\X/2,\Y/2) -- (8/2,\X/2,\Y/2);}}
 \end{scope} 
\end{tikzpicture} 
\label{fig:lattice-2}
\caption{}
\end{figure}
wonderich
  • 2,387
  • Could you please make the example complete by adding the preamble. Some users may not know what view angles you are using etc. –  Dec 12 '18 at 08:20

1 Answers1

3

Edited marmot's answer to get this:

enter image description here

Is this what you want?

\documentclass[tikz,border=3.14159mm]{standalone}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{70}{110}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[black!20]
 \foreach \X in {0,...,8}
 {\foreach \Y in {0,...,8}
 {\draw (\X,\Y,0) -- ++(0,0,8);
 \draw (\X,0,\Y) -- ++(0,8,0);
 \draw (0,\X,\Y) -- ++(8,0,0);}}
\end{scope}

\begin{scope}[black]
 \foreach \X in {2,...,5}
 {\foreach \Y in {2,...,6}
 {\draw (\X,\Y,2) -- ++(0,0,5);}}

 \foreach \X in {2,...,5}
 {\foreach \Z in {2,...,7}
 {\draw (\X,2,\Z) -- ++(0,4,0);}}

 \foreach \Y in {2,...,6}
 {\foreach \Z in {2,...,7}
 {\draw (2,\Y,\Z) -- ++(3,0,0);}}
\end{scope}
\end{tikzpicture} 
\end{document}
nidhin
  • 7,932