我正在尝试在两点之间画一些线,这也会改变颜色的强度,我的想法是这样的:
\documentclass[11pt]{report}
\usepackage{tikz}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\draw [fill=black] (-2,0) circle (2pt);
\draw [fill=black] (2,0) circle (2pt);
\foreach \x in {1,2,...,7}
{
\pgfmathsetmacro{\z}{\x*10}
\foreach \Point in {(0,0),(0,1),(0,-1),(0,2),(0,3),(0,-2),(0,-3)}
{
\draw [black!{\z}] plot [smooth, tension=1] coordinates {(-2,0) \Point (2,0)};
};
}
\end{tikzpicture}
\end{figure}
\end{document}
但它给出了一个错误,我不知道如何修复。谢谢。
答案1
去掉周围的括号\z
。
\documentclass[11pt]{report}
\usepackage{tikz}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\draw [fill=black] (-2,0) circle (2pt);
\draw [fill=black] (2,0) circle (2pt);
\foreach \x in {1,2,...,7}
{
\pgfmathsetmacro{\z}{\x*10}
\foreach \Point in {(0,0),(0,1),(0,-1),(0,2),(0,3),(0,-2),(0,-3)}
{
\draw [black!\z] plot [smooth, tension=1] coordinates {(-2,0) \Point (2,0)};
}
}
\end{tikzpicture}
\end{figure}
\end{document}
但是,看代码时,我很好奇为什么你要用不同的灰度级一遍又一遍地重绘相同的路径。你是否试图做类似的事情
\documentclass[11pt]{report}
\usepackage{tikz}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\draw [fill=black] (-2,0) circle (2pt);
\draw [fill=black] (2,0) circle (2pt);
\foreach \Point [count=\X] in {(0,0),(0,1),(0,-1),(0,2),(0,3),(0,-2),(0,-3)}
{
\pgfmathtruncatemacro{\Z}{\X*10}
\draw [black!\Z] plot [smooth, tension=1] coordinates {(-2,0) \Point (2,0)};
}
\end{tikzpicture}
\end{figure}
\end{document}