我的询问:
1)如何在二维中绘制更密集的网格?
2)如何在三维中绘制更密集的网格?
假设它在二维上仍然是 4 x 4,或者在三维上仍然是 4 x 4 x 4,但我希望每边在网格上的 4 个单元上有 16 或 17 个格点?(所以在二维上是 16 x 16,或者在三维上是 16 x 16 x 16。)
以下是我所拥有的:
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\draw [very thin, lightgray] (0,0) grid (4,4);
\end{tikzpicture}
\label{fig:lattice}
\caption{}
\end{figure}
答案1
这是一个 3D 网格。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{70}{110}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
\foreach \X in {0,1,...,16}
{\foreach \Y in {0,1,...,16}
{\draw (\X/4,\Y/4,0) -- (\X/4,\Y/4,16/4);
\draw (\X/4,0,\Y/4) -- (\X/4,16/4,\Y/4);
\draw (0,\X/4,\Y/4) -- (16/4,\X/4,\Y/4);}}
\end{tikzpicture}
\end{document}
下面的插图显示了视图的作用。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\foreach \Rot in {0,10,...,360}
{\tdplotsetmaincoords{70+15*sin(\Rot)}{\Rot}
\begin{tikzpicture}[tdplot_main_coords]
\path[use as bounding box,tdplot_screen_coords] (-6,-2) rectangle (6,7);
\foreach \X in {0,1,...,16}
{\foreach \Y in {0,1,...,16}
{\draw (\X/4,\Y/4,0) -- (\X/4,\Y/4,16/4);
\draw (\X/4,0,\Y/4) -- (\X/4,16/4,\Y/4);
\draw (0,\X/4,\Y/4) -- (16/4,\X/4,\Y/4);}}
\end{tikzpicture} }
\end{document}
当然,您可以使用非常细的灰线。是的,您可以通过以下方式缩放网格scale=<factor>
。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{70}{110}
\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
\begin{scope}[ultra thin,lightgray]
\foreach \X in {0,1,...,16}
{\foreach \Y in {0,1,...,16}
{\draw (\X/4,\Y/4,0) -- (\X/4,\Y/4,16/4);
\draw (\X/4,0,\Y/4) -- (\X/4,16/4,\Y/4);
\draw (0,\X/4,\Y/4) -- (16/4,\X/4,\Y/4);}}
\end{scope}
\begin{scope}[line width=0.01pt,lightgray,xshift=5cm,scale=0.4]
\foreach \X in {0,1,...,16}
{\foreach \Y in {0,1,...,16}
{\draw (\X/4,\Y/4,0) -- (\X/4,\Y/4,16/4);
\draw (\X/4,0,\Y/4) -- (\X/4,16/4,\Y/4);
\draw (0,\X/4,\Y/4) -- (16/4,\X/4,\Y/4);}}
\end{scope}
\end{tikzpicture}
\end{document}
答案2
答案3
PSTricks 解决方案仅用于比较目的。
\documentclass[pstricks,border=12pt,12pt]{standalone}
\newpsstyle{gridstyle}
{
gridlabels=8pt,
gridfont=Arial,
%
gridcolor=red,
subgridcolor=gray,
%
subgriddiv=5,
%
gridwidth=.8pt,
subgridwidth=.4pt,
%
griddots=10,
subgriddots=5,
}
\begin{document}
\begin{pspicture}[showgrid](5,5)
\end{pspicture}
\end{document}