我想使用 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-是飞机,X=r余弦(φ) 和是=r罪(φ),你会发现函数不依赖于r但只在角度上。所以远离原点X=是= 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}