具有较低样本网格的表面网格图

具有较低样本网格的表面网格图

我有一个非常非线性的函数,我需要一个高采样数。但是,对于这个采样数,网格太细了。我想知道是否可以创建一个曲面图,其中使用高采样率绘制函数,但网格绘制得好像我使用了低采样率。我认为这也有助于着色,因为使用低采样率会用单一颜色绘制补丁(因此图似乎不连续)。这是 MWE:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        colormap/viridis,
        width=176.68246pt,
        zlabel={$u$},
        axis lines*=left,
        view={15}{30},
        xlabel=$x$,
        ylabel=$y$,
        xmin=0,xmax=1,
        ymin=0,ymax=1,
        xtick={0,1},
        ytick={0,1},
%       ztick={0},
        every axis z label/.style={at={(current axis.west)},xshift=-5pt, yshift=30pt,rotate=0}
    ]
     \addplot3[surf,samples=40, domain=0:0.5, y domain=0:1] { 100*x*(1-4*x)*(5-4*x)*(1-2*x)/6  };
     \addplot3[surf,samples=40, domain=0.5:1, y domain=0:1] { 100*(3-4*x)*(1-2*x)*(1-x)*(1+4*x)/6  };
    \end{axis}  
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{fadings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{tikzfadingfrompicture}[name=myfading, line join=round]
\begin{axis}[
axis lines=none,
view={15}{30},
xmin=0, xmax=1,
ymin=0, ymax=1,
]
\addplot3[surf, faceted color=transparent!0, fill=transparent!100, domain=0:0.5, samples=17, domain y=0:1, samples y=9, forget plot] { 100*x*(1-4*x)*(5-4*x)*(1-2*x)/6 };
\addplot3[surf, faceted color=transparent!0, fill=transparent!100, domain=0.5:1, samples=17, domain y=0:1, samples y=9, forget plot] { 100*(3-4*x)*(1-2*x)*(1-x)*(1+4*x)/6 };
\end{axis}
\path (0,0) circle[radius=10]; %encompassing circle for alignment
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
colormap/viridis,
view={15}{30},
xmin=0, xmax=1,
ymin=0, ymax=1,
]
\addplot3[surf, shader=interp, samples=60, domain=0:0.5, y domain=0:1, samples y=2] { 100*x*(1-4*x)*(5-4*x)*(1-2*x)/6 };
\addplot3[surf, shader=interp, samples=60, domain=0.5:1, y domain=0:1, samples y=2] { 100*(3-4*x)*(1-2*x)*(1-x)*(1+4*x)/6 };
\end{axis}
\fill[path fading=myfading, fit fading=false, opacity=0.3] (0,0) rectangle (7,7); 
\end{tikzpicture}
\end{document}

具有粗网格的表面图

相关内容