我正在修改这个偏导数图得到如下结果:
我使用的代码和结果:
\documentclass[tikz]{standalone}
\usetikzlibrary{shadings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1pt},
declare function={f(\x,\y)=2-0.5*pow(\x-1.25,2)-0.5*pow(\y-1,2);}]
\begin{axis}[view={135}{30},colormap/blackwhite,axis lines=middle,%
zmax=2.2,zmin=0,xmin=-0.2,xmax=2.4,ymin=-0.2,ymax=2,%
xlabel=$x$,ylabel=$y$,zlabel=$z$,
xtick=\empty,ytick=\empty,ztick=\empty]
\addplot3[surf,shader=interp,domain=0.6:2,domain y=0.5:1.2,opacity=0.4] {f(x,y)};
\addplot3[thick,domain=0.6:2,samples y=1] ({x},1.2,{f(x,1.2)});
\draw[dashed] (1,0,0) node[above left]{$x_0$} -- (1,1.2,0) node[bullet] (b1) {} -- (0,1.2,0) node[above right]{$y_0$} (1,1.2,0) -- (1,1.2,{f(1,1.2)})node[bullet] {};
\draw (1,1.2,{f(1,1.2)}) -- (0.75,1.2,{f(1,1.2)+0.2}) coordinate[pos=0.5] (aux1);
\draw[opacity=0.5,dashed] (2,1.2,0) -- (0.6,1.2,0) -- (0.6,1.2,2.2) -- (2,1.2,2.2) -- cycle;
\draw[opacity=0.5,dashed] (1,0.5,0) -- (1,1.9,0) -- (1,1.9,2.2) -- (1,0.5,2.2) -- cycle;
\addplot3[surf,shader=interp,domain=0.6:2,domain y=1.2:1.9,opacity=0.4] {f(x,y)};
\addplot3[thick,domain=0.5:1.9,samples y=1] (1,{x},{f(1,x)});
\draw (1,1.2,{f(1,1.2)}) -- (1,0.2,{f(1,1.2)+0.2}) coordinate[pos=0.5] (aux2);
\end{axis}
\end{tikzpicture}
\end{document}
我想要做的是擦除表面上方的平面。我该怎么做?
答案1
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{shadings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1pt},
declare function={f(\x,\y)=2-0.5*pow(\x-1.25,2)-0.5*pow(\y-1,2);}]
\begin{axis}[view={135}{30},colormap/blackwhite,axis lines=middle,%
zmax=2.2,zmin=0,xmin=-0.2,xmax=2.4,ymin=-0.2,ymax=2,%
xlabel=$x$,ylabel=$y$,zlabel=$z$,
xtick=\empty,ytick=\empty,ztick=\empty]
\addplot3[surf,shader=interp,domain=0.6:2,domain y=0.5:1.2,opacity=0.4] {f(x,y)};
\addplot3[thick,domain=0.6:2,samples y=1] ({x},1.2,{f(x,1.2)});
\draw[dashed] (1,0,0) node[above left]{$x_0$} -- (1,1.2,0) node[bullet] (b1) {} -- (0,1.2,0) node[above right]{$y_0$} (1,1.2,0) -- (1,1.2,{f(1,1.2)})node[bullet] {};
\draw (1,1.2,{f(1,1.2)}) -- (0.75,1.2,{f(1,1.2)+0.2}) coordinate[pos=0.5] (aux1);
\draw[opacity=0.5,dashed] (2,1.2,{f(2,1.2)}) -- (2,1.2,0) -- (0.6,1.2,0) -- (0.6,1.2,{f(0.6,1.2)});
\draw[opacity=0.5,dashed] (1,0.5,{f(1,0.5)}) -- (1,0.5,0) -- (1,1.9,0) -- (1,1.9,{f(1,1.9)});
\addplot3[surf,shader=interp,domain=0.6:2,domain y=1.2:1.9,opacity=0.4] {f(x,y)};
\addplot3[thick,domain=0.5:1.9,samples y=1] (1,{x},{f(1,x)});
\draw (1,1.2,{f(1,1.2)}) -- (1,0.2,{f(1,1.2)+0.2}) coordinate[pos=0.5] (aux2);
\end{axis}
\end{tikzpicture}
\end{document}