我想使用 PGFPlots 繪製函數 xy/(x^2+2y^2) 。這就是我想要的:
請考慮這個 MWE:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\pgfplotsset{soldot/.style={color=black,only marks,mark=*}}
\pgfplotsset{holdot/.style={color=red,fill=white,very thick,only marks,mark=*}}
\begin{document}
\begin{center}
\begin{tikzpicture}[declare function={f(\x,\y)=(\x*\y)/(\x*\x+2*\y*\y);}]
\begin{axis} [
axis on top,
axis equal image,
axis lines=center,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zmin=-1,
zmax=1,
ztick={-1,0,0.33,1},
zticklabels={$-1$,$0$,$1/3$,$1$},
ticklabel style={font=\tiny},
legend pos=outer north east,
legend style={cells={align=left}},
legend cell align={left},
view={-135}{25},
]
\addplot3[surf,mesh/ordering=y varies,shader=interp,domain=-1:1,domain y=-1:1,samples=61, samples y=61] {f(x,y)};;
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
MWE 輸出具有令人難以置信的大變焦,因此我想調整繪圖的大小,但不使用scale
其他命令,例如enlarge limits
.然而一切的結果都是徒勞;我無法重現我想要的視覺外觀。
謝謝!
答案1
不是問題(LaTeX 部分)的答案。但是,如果您使用極座標X-y飛機,X=r餘弦(φ) 和y=r罪(φ),你會看到該函數不依賴r但僅限於角度。那麼遠離原點X=y= 0 所有資訊已經在一維圖中。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}[declare function={fan(\t)=-(sin(2*\t)/(-3 + cos(2*\t)));}]
\begin{axis}
\addplot[domain=0:360,smooth,samples=101] {fan(x)};
\end{axis}
\end{tikzpicture}
\end{document}
這會產生 3d 平滑圖。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\pgfplotsset{soldot/.style={color=black,only marks,mark=*}}
\pgfplotsset{holdot/.style={color=red,fill=white,very thick,only marks,mark=*}}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=(\x*\y)/(\x*\x+2*\y*\y);
fan(\t)=-(sin(2*\t)/(-3 + cos(2*\t)));}]
\begin{axis} [width=18cm,
axis on top,
axis equal image,
axis lines=center,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zmin=-1,
zmax=1,
ztick={-1,0,0.33,1},
zticklabels={$-1$,$0$,$1/3$,$1$},
ticklabel style={font=\tiny},
legend pos=outer north east,
legend style={cells={align=left}},
legend cell align={left},
view={-135}{25},
data cs=polar,
]
\addplot3[surf,mesh/ordering=y varies,shader=interp,domain=0:360,
domain y=0:1,samples=61, samples y=21,
z buffer=sort] { fan(x)};
\addlegendentry{{$f(x,y)$}}
\end{axis}
\end{tikzpicture}
\end{document}