使用 tikz-3dplot 的 3-d 示例

使用 tikz-3dplot 的 3-d 示例

我正在尝试重新创建: 在此处输入图片描述

这是我目前拥有的代码:

\documentclass{article}     
\usepackage{tikz,tikz-3dplot}      
\begin{document}      
\tdplotsetmaincoords{70}{110}     
\begin{tikzpicture}[scale=1.5,tdplot_main_coords]      
\draw[thick,black,->] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$};       
\draw[thick,black,->] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$};       
\draw[thick,black,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$};        
\draw [blue,fill=blue,opacity=.3,shading=radial] plot [smooth,tension=1]  
    coordinates{(1,0,1) (0,0,.25) (.5,1.5,.75) (0,2,1.25) (-1,1,1.25) (-.5,-.5,1)};        
\draw [blue] plot [smooth,tension=1] coordinates{(1,0,1) (0,0,.25) (.5,1.5,.75)    (0,2,1.25) (-1,1,1.25) (-.5,-.5,1)};         
\end{tikzpicture}        
\end{document} 

输出:

在此处输入图片描述

有什么建议可以改进该程序吗?

答案1

我包含了一些库并注释掉了您想要改善结果时可能需要的东西。

\documentclass{article}     
\usepackage{tikz,tikz-3dplot}    
\usetikzlibrary{intersections,fadings,decorations.pathreplacing} %  interesection is not needed
%\usetikzlibrary{shadows.blur}

\begin{document}

\tdplotsetmaincoords{75}{110}
\begin{tikzpicture}[tdplot_main_coords,scale=3.14]

% restore these if you want to see where the axes point
\draw[thick,->] (0,0,0) coordinate(O) -- (1.5,0,0) node[anchor=north east] (x) {$x$};
\draw[thick,->] (0,0,0) -- (0,1.5,0) node[anchor=north west] (y) {$y$};
\draw[thick,->] (0,0,0) -- (0,0,2.5) node[anchor=south] (z) {$z$};
\begin{scope}[xshift=0mm,rotate=-10]
% \tikzset{% https://tex.stackexchange.com/a/328561/121799
%     render blur shadow/.prefix code={
%       \colorlet{black}{orange}
%     }
%   }
\tikzfading[name=fade right,
            left color=transparent!00,
            right color=transparent!60] ;
\filldraw[orange,path fading=fade right,fill opacity=0.5, 
% blur shadow={shadow blur
% steps=10,shadow xshift=0pt,shadow yshift=0pt,shadow scale=1.15,orange}
]  plot[variable=\x,samples=180,domain=-90:270]
({1.2*cos(\x)},{sin(\x)},{0});
% \filldraw[white,path fading=fade right,overlay] (-1.5,-1.3,1) --  (1.5,-1.3,1) -- 
% (1.5,1.3,1) -- (-1.5,1.3,1) -- cycle;
\end{scope}

\coordinate[label={[name=Plabel,xshift=1.5cm,yshift=1cm]above right:{$(x,y,f(x,y))$}}] (P) at (0.2,0.5,1.2);
\draw[-latex,shorten >=2.5pt] (Plabel) --(P);
\fill (P) circle (1pt);
\coordinate[label=below:{$(x,y,0)$}] (Q) at (0.2,0.5,0);
\fill (Q) circle (1pt);
\draw[thick,] (P) -- (Q);
\draw[thick,decoration={brace,raise=2.5pt},decorate] (P) -- (Q)
node[midway,right=2mm]{$f(x,y)$};


\draw[fill=blue,fill opacity=0.2,name path=back,->]
plot[variable=\x,samples=180,domain=50:270]
({1.2*cos(\x)},{sin(\x)},{1.2+0.4*cos(2*\x)}) to[out=30,in=160] cycle;
\draw[fill=blue,fill opacity=0.2,name path=front]
plot[variable=\x,samples=180,domain=-90:50]
({1.2*cos(\x)},{sin(\x)},{1.2+0.4*cos(2*\x)})
to[out=160,in=30] cycle; 


\end{tikzpicture}
\end{document} 

在此处输入图片描述

相关内容