PGFPlots를 사용하여 x^2+y^2

PGFPlots를 사용하여 x^2+y^2

, 로 D정의된 몸체를 그리고 싶습니다 .x^2+y^2<=9z<=16-x^2-y^2z>=0

불투명도를 낮추고 그래프를 그린 x^2+y^2=9다음 교차점을 채워(또는 패턴을 사용하여) 이전 표현식으로 정의된 몸체를 만들어야 합니다.z=16-x^2-y^2z=0D

내가 원하는 것

그러나 작업을 완료할 수 없습니다. MWE는 다음과 같습니다.

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.25,.81)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
            \addplot3[orange,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({r*cos(t)},{r*sin(t)},{16-r*r});   % z=16-x^2-y^2
            \addlegendentry{\(16-x^2-y^2\)}
            \addplot3[green,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({3*cos(t)},{3*sin(t)},{0});   % x^2+y^2=9
            \addlegendentry{\(x^2+y^2=9\)}
            \fill[cyan,opacity=.5] (3,3,0) -- (3,-3,0) -- (-3,-3,0) 
        -- (-3,3,0);    % z=0
            \addlegendentry{\(z=0\)}    % This label is not showing because we used 'fill', not 'addplot3'
            % Here should be the code of the intersection of the three surfaces...
        \end{axis}
    \end{tikzpicture}
\end{center}

\end{document}

내가 뭘 한거지

편집하다.많은 감사마모트내가 원하는 것을 부분적으로 완료하도록 도와준 사람:

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.45,.85)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
            \addplot3[opacity=.5,surf,shader=interp,colormap={orange}{color=(orange!50) color=(orange!50)},variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({r*cos(t)},{r*sin(t)},{16-r*r});  % z=16-x^2-y^2
            \addlegendentry{\(z=16-x^2-y^2\)}
            \addplot3[opacity=.5,surf,shader=interp,domain=0:360,domain y=0:16,colormap={green}{color=(green!50) color=(green!50)}] ({3*cos(x)},{3*sin(x)},{y}); % x^2+y^2=9
            \addlegendentry{\(x^2+y^2=9\)}
            %\fill[cyan,opacity=.5] (4,4,0) -- (4,-4,0) -- (-4,-4,0) -- (-4,4,0);    % z=0
            \addplot3[fill=cyan,opacity=.5,domain=-4:4, domain y=-4:4] (x,y,0);
            \addlegendentry{\(z=0\)}
        \end{axis}
    \end{tikzpicture}
\end{center}

\end{document}

새로운 MWE

그러나 우리는 다음을 수행해야 합니다.

  • 출력을 수정합니다.z=0fill( 플롯이 아니기 때문에 범례를 추가할 수 없기 때문에 사용하고 싶지 않습니다 .)
  • 고체를 채우다D패턴 사용:패턴을 이용한 솔리드또는 채우기:꽉 채우는 중프로그래밍 시간이 덜 필요한 것.

관심 있는 링크:

감사해요!!

답변1

어때?

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.45,.85)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
            \addplot3[opacity=.5,surf,shader=interp,colormap={orange}{color=(orange!50) color=(orange!50)},variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({r*cos(t)},{r*sin(t)},{16-r*r});  % z=16-x^2-y^2
            \addlegendentry{\(z=16-x^2-y^2\)}
            \addplot3[opacity=.5,surf,shader=interp,domain=0:360,domain y=0:16,colormap={green}{color=(green!50) color=(green!50)}] ({3*cos(x)},{3*sin(x)},{y}); % x^2+y^2=9
            \addlegendentry{\(x^2+y^2=9\)}
            %\fill[cyan,opacity=.5] (4,4,0) -- (4,-4,0) -- (-4,-4,0) -- (-4,4,0);    % z=0
            \addplot3[surf,shader=interp,opacity=.5,domain=-4:4, domain y=-4:4,
            colormap={dull}{color=(cyan) color=(cyan)},opacity=0.5] {0};
            \addlegendentry{\(z=0\)}
            \addplot3[mesh,color=gray,ultra thin,domain=0:360,domain y=0:4,z
            buffer=sort,samples=31,samples y=41] 
            ({min(y,3)*cos(x)},{min(y,3)*sin(x)},{16-y*y});
        \end{axis}
    \end{tikzpicture}
\end{center}

\end{document}

여기에 이미지 설명을 입력하세요

? 그것은 불쾌한 오리를 위한 좋은 우리가 될 수도 있습니다. ;-)

이것은 표면을 보여줍니다. 원래 플롯으로 무엇을 하고 싶은지 모르겠습니다.

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.25,.81)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
%             \addplot3[orange,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({r*cos(t)},{r*sin(t)},{16-r*r});   % z=16-x^2-y^2
%             \addlegendentry{\(16-x^2-y^2\)}
%             \addplot3[green,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({3*cos(t)},{3*sin(t)},{0});   % x^2+y^2=9
%             \addlegendentry{\(x^2+y^2=9\)}
%             \fill[cyan,opacity=.5] (3,3,0) -- (3,-3,0) -- (-3,-3,0) 
%         -- (-3,3,0);    % z=0
%             %\addlegendentry{\(z=0\)}    % This label is not showing because we used 'fill', not 'addplot3'
            % Here should be the code of the intersection of the three surfaces...
            \addplot3[surf,shader=interp,domain=0:360,domain y=0:7,z buffer=sort] 
            ({3*cos(x)},{3*sin(x)},{y});
            \addplot3[data cs=polar,surf,shader=interp,domain=0:360,domain y=0:3] {16-y*y};
        \end{axis}
    \end{tikzpicture}
\end{center}
\end{document}

여기에 이미지 설명을 입력하세요

이것은 나에게 독버섯처럼 보입니다.

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.25,.81)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
%             \addplot3[orange,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({r*cos(t)},{r*sin(t)},{16-r*r});   % z=16-x^2-y^2
%             \addlegendentry{\(16-x^2-y^2\)}
%             \addplot3[green,opacity=.5,samples=51,samples y=21,variable=t,variable y=r,domain=0:360,domain y=0:2*pi,restrict z to domain=0:16] ({3*cos(t)},{3*sin(t)},{0});   % x^2+y^2=9
%             \addlegendentry{\(x^2+y^2=9\)}
%             \fill[cyan,opacity=.5] (3,3,0) -- (3,-3,0) -- (-3,-3,0) 
%         -- (-3,3,0);    % z=0
%             %\addlegendentry{\(z=0\)}    % This label is not showing because we used 'fill', not 'addplot3'
            % Here should be the code of the intersection of the three surfaces...
            \addplot3[surf,shader=interp,domain=0:360,domain y=0:7,z
            buffer=sort,colormap=
        {greenblack}{color=(green!50!black) color=(green)}] 
            ({3*cos(x)},{3*sin(x)},{y});
            \addplot3[data cs=polar,surf,shader=interp,domain=0:360,domain y=0:3,color=orange] {16-y*y};
        \end{axis}
    \end{tikzpicture}
\end{center}
\end{document}

여기에 이미지 설명을 입력하세요

한 번에 그릴 수도 있습니다.

\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}

\begin{document}

\begin{center}
    \begin{tikzpicture}
        \begin{axis} [
                axis on top,
                axis lines=center,
                xlabel=$x$,
                ylabel=$y$,
                zlabel=$z$,
                xmin=-5,
                ymin=-5,
                zmin=-1,
                xmax=5,
                ymax=5,
                zmax=17,
                xtick={-4,-3,0,3,4},
                xticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ytick={-4,-3,0,3,4},
                yticklabels={$-4$,$-3$,$0$,$3$,$4$},
                ztick={0,16},
                zticklabels={$0$,$16$},
                ticklabel style={font=\tiny},
                legend pos=outer north east,
                legend style={at={(1.25,.81)},anchor=north east},
                legend cell align={left},
                view={135}{25}
            ]
            % Here should be the code of the intersection of the three surfaces...
            \addplot3[surf,shader=interp,domain=0:360,domain y=0:4,z
            buffer=sort,colormap=
        {greenorange}{color=(green!80!black) color=(orange)},samples=31,samples
        y=41] 
            ({min(y,3)*cos(x)},{min(y,3)*sin(x)},{16-y*y});
        \end{axis}
    \end{tikzpicture}
\end{center}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보