
我發現 產生的圖形\addplot[mesh]
是由不同顏色的線段組成的。
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
samples=50,
point meta rel=axis wide,
point meta=y,
]
\addplot[mesh,thick] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}
顏色過渡不平滑。我想讓線條顏色平滑,我將上面的程式碼重寫為
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
samples=50,
point meta rel=axis wide,
point meta=y,
colormap access=direct,
shader=interp
]
\addplot[mesh,thick] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}
這會產生相同顏色的線條。如何讓線條顏色根據點元變化且顏色過渡平滑?
答案1
不要在家嘗試做這個 ! (因為這很愚蠢;)
......!)
說真的,你應該要增加samples
曲線的數量。
輸出
程式碼
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
samples=51,
view={0}{0},
]
\addplot3
[
surf,
line width=2mm,
point meta=z,
shader=interp,
samples y=2,
y domain=0:.05,
]
({x-y*cos(deg(x)},0,{sin(deg(x))+y});
\end{axis}
\end{tikzpicture}
\end{document}