
によって生成された図形は、\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}