降低变量 x 的不透明度而不改变颜色图

降低变量 x 的不透明度而不改变颜色图

我想在不改变颜色图的情况下,沿 x 变量降低图片管的不透明度。这是我的代码:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{tikz}
\usetikzlibrary{shadows,
                positioning,
                decorations,
                decorations.text,
                decorations.markings,
                decorations.pathmorphing,
                calc,
                fit,
                intersections,
                shapes,
                patterns,
                angles,
                quotes,}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines=center,
        axis equal image,
        view={15}{30},
        xlabel={$x$},
        xtick=\empty,
        xlabel style={anchor=west},
        ylabel={$y$},
        ytick=\empty,
        ylabel style={anchor=west},
        zlabel={$\vec{\omega}$},
        ztick=\empty,
        zlabel style={anchor=south},
        domain=0.15:0.4,
        y domain=0:2*pi,
        xmin=-0.1, xmax=0.65,
        ymin=-0.1, ymax=0.6,
        zmin=-0.1, zmax=0.4,
        mesh/interior colormap={blackgreen}{
            color=(white!70!gray) color=(black!50!gray)},
        colormap={blueblack}{color=(blue) color=(cyan)},
        samples=5,
        samples y=15,
        %z buffer=sort,
 ]
\coordinate (0) at (axis cs:0,0,0);
\coordinate (x) at (axis cs:1,0,0);
\coordinate (a) at (axis cs:0.43,0.46,0.043);
\coordinate (a1) at (axis cs:0.55,0.58,0.043);
\coordinate (b) at (axis cs:0.46,0.43,-0.043);
\coordinate (b1) at (axis cs:0.55,0.52,-0.043);
\addplot3[black,fill=white,fill opacity=.5] ({0.07*cos(deg(y))},{0.07*sin(deg(y))},{0});
\addplot3[mark=none,surf,
                    %point meta rel=per plot,
                    %point meta=x,
                    %opacity=(1000/\pgfplotspointmetatransformed),
                    y domain=-2*pi/3:pi/3] (
    {x+0.035*(-cos(deg(y))+1)},
    {x+0.035*(+cos(deg(y))+1)},
    {0.05*sin(deg(y))});
\node[circle,inner sep=1pt,shade,ball color=red!60!white,white,scale=1.3]
    (m) at (axis cs:0.3,0.3,0) {$m$};
\draw[red,-stealth] (0) -- (m) node[black,midway,above] {$r$};
%\addplot3[black,surf,opacity=.1,y domain=pi/3:4*pi/3] (
    %{x+0.035*(-cos(deg(y))+1)},
    %{x+0.035*(+cos(deg(y))+1)},
    %{0.05*sin(deg(y))});
    \pic[pic text=$\omega t$,
            -stealth,
            thick,
            draw=orange,
            angle eccentricity=0.75,
            angle radius=1.1cm]
  {angle=x--0--m};
    \draw[dashed] (a) -- (a1);
    \draw[dashed] (b) -- (b1);
\end{axis}
\end{tikzpicture}
\end{document}

答案1

你可以作弊并在顶部绘制一个褪色的矩形。

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{tikz}
\usetikzlibrary{shadows,
                positioning,
                decorations,
                decorations.text,
                decorations.markings,
                decorations.pathmorphing,
                calc,
                fit,
                intersections,
                shapes,
                patterns,
                angles,
                quotes,}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        axis lines=center,
        axis equal image,
        view={15}{30},
        xlabel={$x$},
        xtick=\empty,
        xlabel style={anchor=west},
        ylabel={$y$},
        ytick=\empty,
        ylabel style={anchor=west},
        zlabel={$\vec{\omega}$},
        ztick=\empty,
        zlabel style={anchor=south},
        domain=0.15:0.4,
        y domain=0:2*pi,
        xmin=-0.1, xmax=0.65,
        ymin=-0.1, ymax=0.6,
        zmin=-0.1, zmax=0.4,
        mesh/interior colormap={blackgreen}{
            color=(white!70!gray) color=(black!50!gray)},
        colormap={blueblack}{color=(blue) color=(cyan)},
        samples=5,
        samples y=15,
        %z buffer=sort,
 ]
\coordinate (0) at (axis cs:0,0,0);
\coordinate (x) at (axis cs:1,0,0);
\coordinate (a) at (axis cs:0.43,0.46,0.043);
\coordinate (a1) at (axis cs:0.55,0.58,0.043);
\coordinate (b) at (axis cs:0.46,0.43,-0.043);
\coordinate (b1) at (axis cs:0.55,0.52,-0.043);
\addplot3[black,fill=white,fill opacity=.5] ({0.07*cos(deg(y))},{0.07*sin(deg(y))},{0});
\addplot3[mark=none,surf,
                    point meta rel=per plot,
%                      point meta=-x-y,
%                      opacity=(1000/(\pgfplotspointmetatransformed+1)),
                    y domain=-2*pi/3:pi/3] (
    {x+0.035*(-cos(deg(y))+1)},
    {x+0.035*(+cos(deg(y))+1)},
    {0.05*sin(deg(y))});
\fill[path fading=west,white]
(axis cs:{0.1+0.035*(-cos(deg(-2*pi/3))+1)},{0.05+0.035*(-cos(deg(-2*pi/3))+1)},{0.05*sin(deg(-2*pi/3))})
--
(axis cs:{0.45+0.035*(-cos(deg(-2*pi/3))+1)},{0.35+0.035*(-cos(deg(-2*pi/3))+1)},{0.05*sin(deg(-2*pi/3))})
--
(axis cs:{0.4+0.035*(-cos(deg(2*pi/3))+1)},{0.45+0.035*(-cos(deg(2*pi/3))+1)},{0.05*sin(deg(2*pi/3))})
--
(axis cs:{0.1+0.035*(-cos(deg(2*pi/3))+1)},{0.15+0.035*(-cos(deg(2*pi/3))+1)},{0.05*sin(deg(2*pi/3))})
-- cycle;
\node[circle,inner sep=1pt,shade,ball color=red!60!white,white,scale=1.3]
    (m) at (axis cs:0.3,0.3,0) {$m$};
\draw[red,-stealth] (0) -- (m) node[black,midway,above] {$r$};
%\addplot3[black,surf,opacity=.1,y domain=pi/3:4*pi/3] (
    %{x+0.035*(-cos(deg(y))+1)},
    %{x+0.035*(+cos(deg(y))+1)},
    %{0.05*sin(deg(y))});
    \pic[pic text=$\omega t$,
            -stealth,
            thick,
            draw=orange,
            angle eccentricity=0.75,
            angle radius=1.1cm]
  {angle=x--0--m};
    \draw[dashed] (a) -- (a1);
    \draw[dashed] (b) -- (b1);
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容