1

I want a cylinder of radius 1 and height 1, centered on the origin above the xy plane and the part of a sphere of radius sqrt(2) centered at the origin, that covers the cylinder.

sphere on top of a cylinder

This is what I have managed to do

\documentclass[tikz,border=3mm]{standalone} 
\usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, view={340}{25}, domain=0:5, y domain=0:2*pi, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, zmin=0.0, samples=30, xlabel=$x$, ylabel=$y$, zlabel={$z$}, ] \addplot3 [surf, z buffer=sort, opacity=0.6] ({cos(deg(y))},{sin(deg(y))},{x}); \end{axis} \end{tikzpicture} \end{document}

  • Welcome to TeX.SE. Your question is asking to draw a figure without providing any starting point or a specific issue where you run into trouble. This is not really the type of questions that are a good fit for this site, questions should be focused on a specific problem so other people with the same problem can also benefit from reading the question and the answer. Also it is appreciated to provide a starting point in code so people that might want to answer don't need to start from scratch. See https://texample.net/tikz/examples/ if you can find some code to serve as a starting point. – Marijn Nov 19 '20 at 17:40
  • For now I will vote to close the question, if you can make it more specific and add code that can be modified then you can edit your question here and then the question can be reopened. – Marijn Nov 19 '20 at 17:41
  • 5
    I’m voting to close this question because it is a request to provide code without a starting point or specific issue to be answered. – Marijn Nov 19 '20 at 17:42

2 Answers2

1

This gives you possible parametrizations of the plots. So it is a start.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[point meta max=1]
 \addplot3[surf,shader=flat,samples=2,samples y=37,
    domain=0:1,domain y=0:360,z buffer=sort,
    point meta=0,opacity=0.5] ({cos(y)},{sin(y)},x);
 \addplot3[surf,shader=interp,samples=15,samples y=37,
    domain=45:90,domain y=0:360,z buffer=sort,
    point meta=0.5] ({sqrt(2)*cos(y)*cos(x)},
        {sqrt(2)*sin(y)*cos(x)},{sqrt(2)*sin(x)});
\end{axis}
\end{tikzpicture}
\end{document}
0

Just got it!

\documentclass{standalone} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.9, colormap/blackwhite}

\begin{document} \begin{tikzpicture} \begin{axis}[ axis equal, axis lines=middle, view={110}{25}, domain=0:5, y domain=0:2*pi, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, zmin=0.0, zmax=1.9, samples=35, xlabel=$x$, ylabel=$y$, zlabel={$z$}, ] \addplot3 [surf, z buffer=sort, opacity=0.6, domain=0:1, color=black!90] ({cos(deg(y))},{sin(deg(y))},{x}); \addplot3[surf,domain=45:90,domain y=0:360,z buffer=sort, opacity=0.6, color=black!50] ({sqrt(2)cos(y)cos(x)}, {sqrt(2)sin(y)cos(x)},{sqrt(2)*sin(x)}); \end{axis} \end{tikzpicture} \end{document}

Thanks @abcdefg