
3D 曲線のさまざまなビューをプロットしようとしていますが、軸とプロットのスタイルを最初から定義したいのですが、それができません。コードと結果は次のとおりです。
\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function ={
ex(\x)=cos(\x)*sin(2*\x);
ye(\x)=cos(\x)*cos(2*\x);
ze(\x)=sin(\x);
}
]
\pgfplotsset{
every axis post/.append style={
trig format plots=rad,
scale=0.7
}
every axis plot/.append style={
blue,
domain=0:2*pi,
samples=120
}
}
\begin{axis}
\addplot3 ({ex(x)},{ye(x)},{ze(x)});
\end{axis}
\begin{axis}[xshift=7cm, view/h=120,view/v=90]
\addplot3 ({ex(x)},{ye(x)},{ze(x)});
\end{axis}
\end{tikzpicture}
\end{document}
私が欲しいのは次のものです (上記のすべてのオプションをすべてのaxis
環境とすべての\addplot
マクロに書き込むことで得られます):
曲線の色は反映されますが、その他のオプションは反映されません。キーに正しい構文を使用しているかどうかはよくわかりません。エラーなしでコンパイルできるので、明らかに正しい構文ですが、目的を達成するために何かが欠けているのは明らかで、マニュアルでは見つけられないようです。よろしくお願いします。
答え1
pgfplotsset
2 つの部分 (every axis post
部分と部分)の間にコンマを忘れました。また、一般設定をトリガーするには、その後にevery axis plot
空のオプションを設定する必要があります。[]
\addplot3
MWE:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[
declare function ={
ex(\x)=cos(\x)*sin(2*\x);
ye(\x)=cos(\x)*cos(2*\x);
ze(\x)=sin(\x);
}
]
\pgfplotsset{
every axis post/.append style={
trig format plots=rad,
scale=0.7
},
every axis plot/.append style={
purple,
domain=0:2*pi,
samples=120
}
}
\begin{axis}
\addplot3[] ({ex(x)},{ye(x)},{ze(x)});
\end{axis}
\begin{axis}[xshift=7cm, view/h=120,view/v=90]
\addplot3[] ({ex(x)},{ye(x)},{ze(x)});
\end{axis}
\end{tikzpicture}
\end{document}
結果: