如何使用 pgfplots 显示表面上特定方向的网格

如何使用 pgfplots 显示表面上特定方向的网格

我用它pgfplots来表示一般的圆柱表面,得到如下效果:

在此处输入图片描述

我怎样才能只显示网格X轴?我也遇到了添加文本的问题。

我迄今为止的代码:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}[scale=1.25]
\begin{axis}[
    xmin=-1,
    ymin=-1,
    zmin=-1,
    xmax=3,
    ymax=3,
    zmax=4,
    axis lines = center,
    xticklabel style = {font=\tiny},
    yticklabel style = {font=\tiny},
    zticklabel style = {font=\tiny},
    label style={font=\tiny},
    xlabel = $x$,
    ylabel = $y$,
    zlabel = $z$,
    view={135}{30}
            ]
        \addplot3[surf,domain=0:3,y domain= 0:2,blue!70!white,opacity=0.4,faceted color=blue!70!white]
            (x,y,{-(y-1)^3+2});
        \addplot3[surf,domain=1.5:1.51,y domain= 0:2,red!70!white,opacity=0.4,faceted color=red!70!white]
            (x,y,{-(y-1)^3+2});
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-1, xmax=3,
ymin=-1, ymax=3,
zmin=-1, zmax=4,
axis lines=center,
ticklabel style={font=\tiny},
label style={font=\tiny},
xlabel=$x$, ylabel=$y$, zlabel=$z$,
view={135}{30},
]
\addplot3[
surf,
domain=0:3,
y domain=0:2,
blue!70!white,
opacity=0.4,
faceted color=blue!70!white,
samples=2,
samples y=30,
] (x,y,{-(y-1)^3+2});
\addplot3[
red!70!white,
domain=0:2,
samples y=1,
thick,
smooth,
] (1.5,x,{-(x-1)^3+2});
\draw (0.8,1.2,0) -- (1,2,0) node[font=\tiny, below, align=left]{Lines through\\generating curve\\parallel to $x-$axis};
\end{axis}
\end{tikzpicture}
\end{document}

线面图

相关内容