2

I am trying to fill a self-shaped area (badly done with \draw commands) with a color, yet dont know how to tell tikz what the area in question is. The following creates my drawing and the area i want to be colored is the intersection of the cubic-like volume with the area it cuts.

    \documentclass[11pt,a4paper,onesided]{report}

\usepackage[ngerman]{babel}



\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{pgfplots}


\usetikzlibrary{calc,fit,patterns,decorations.markings,matrix,3d}
\begin{document}

    \begin{tikzpicture}[scale=1]
    \draw[thin,->] (-2,0) -- (5,0);
    \draw[thin,->] (0,-2) -- (0,3) node[at end, anchor = east] {$\mathbb{R}^{d-n}$};
    \draw[very thick,] (0,-1.5) -- (0,1.5) ;
    \draw[->] (-2,1) to [out=30,in=150] (-0.1,1);
    \node[] at (-2.3,.9) {$T_0'$};
    \draw[->] (-1,-1.9) to [out=-10,in=-150] (1.4,-1);
    \node[] at (-1.3,-1.9) {$\hat{T_0}$};
    %Zylinder
    \draw[] (1.5,-1.5) -- (1.5,1.5);
    \draw[] (3.5,-1.5) -- (3.5,1.5);
    \begin{scope}[canvas is zx plane at y=0]
    \draw (0,2.5) circle (2cm);
    \draw[fill=gray,opacity=0.5] (0,2.5) circle (1cm);
    %
    \draw[->] (-2,0) -- (3,0);
    \end{scope}

    \begin{scope}[canvas is zx plane at y=1.5]
    \draw (0,2.5) circle (1cm);
    \end{scope}

    \begin{scope}[canvas is zx plane at y=-1.5]
    \draw (0,2.5) circle (1cm);
    \end{scope}     

    \begin{scope}[every node/.append style={
        xslant=1,sloped}
    ]    
    \node at (2.4,-.2) {\scalebox{1}[.7]{$T_0$}};
    \node at (4,.4) {\scalebox{1}[.7]{$T$}};
    \node at (-.8,-.2) {\scalebox{1}[.7]{$\mathbb{R}^n$}};
    \end{scope}

    \draw[] (6,-2) to [out=20,in=160] (11,-2.5);
    \draw[] (11,-2.5) to [out=90,in=220] (13,2.5);
    \draw[] (13,2.5) to [out=-200,in=10] (8,3.5);

    \draw[] (7,-.5) to [out=20,in=160] (10,-1);
    \draw[] (10,-1) to [out=90,in=220] (11,1.8);
    \draw[] (11,1.8) to [out=-200,in=10] (8.5,2.5);
    \draw[] (8.5,2.5) to [out=-150,in=100] (7,-.5);     

    \draw[] (7.5,.7) to [out=0,in=140] (9,0.2);
    \draw[] (9,.2) to [out=70,in=240] (9.8,1.4);
    \draw[dashed] (9.8,1.4) to [out=160,in=0] (8.3,1.8);
    \draw[dashed] (8.3,1.8) to [out=-150,in=70] (7.5,.7);

    \draw[] (9,.2) -- (9,1.3);
    \draw[] (7.5,.7) -- (7.5,1.8);
    \draw[] (9.8,1.4) -- (9.8,2.5);
    \draw[] (8.3,1.8) -- (8.3,2.9);

    \draw[] (7.5,1.8) to [out=0,in=140] (9,1.3);
    \draw[] (9,1.3) to [out=70,in=240] (9.8,2.5);
    \draw[] (9.8,2.5) to [out=160,in=0] (8.3,2.9);
    \draw[] (8.3,2.9) to [out=-150,in=70] (7.5,1.8);

    \draw[dashed] (9,.2) -- (9,-.9);
    \draw[dashed] (7.5,.7) -- (7.5,-.4);
    \draw[dashed] (9.8,1.4) -- (9.8,.3);
    \draw[dashed] (8.3,1.8) -- (8.3,.7);        

    \draw[dashed] (7.5,-.4) to [out=0,in=140] (9,-0.9);
    \draw[dashed] (9,-.9) to [out=70,in=240] (9.8,.3);
    \draw[dashed] (9.8,.3) to [out=160,in=0] (8.3,.7);
    \draw[dashed] (8.3,.7) to [out=-150,in=70] (7.5,-.4);
    \end{tikzpicture}

\end{document

I hope you can help me with this little problem of mine and if you got any tips on how to draw this image less hand-made and more structured, feel free to recommend! (Also, can you not upload .pdf data to a post? would like to upload the compiled image as help too)

Thanks in advance.

4

One option:

enter image description here

I used

    \fill[cyan,fill opacity=0.4] (7.5,.7) to [out=0,in=140] (9,0.2)
    to [out=70,in=240] (9.8,1.4)
    to [out=160,in=0] (8.3,1.8)
    to [out=-150,in=70] cycle;

(one closed path) for the filling, and then

    \draw[] (7.5,.7) to [out=0,in=140] (9,0.2)
    to [out=70,in=240] (9.8,1.4);
    \draw[dashed] (9.8,1.4) to [out=160,in=0] (8.3,1.8)
    to [out=-150,in=70] (7.5,.7);

for drawing.

The complete code:

\documentclass[11pt,a4paper,onesided]{report}

\usepackage[ngerman]{babel}



\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{pgfplots}


\usetikzlibrary{calc,fit,patterns,decorations.markings,matrix,3d}
\begin{document}

    \begin{tikzpicture}[scale=1]
    \draw[thin,->] (-2,0) -- (5,0);
    \draw[thin,->] (0,-2) -- (0,3) node[at end, anchor = east] {$\mathbb{R}^{d-n}$};
    \draw[very thick,] (0,-1.5) -- (0,1.5) ;
    \draw[->] (-2,1) to [out=30,in=150] (-0.1,1);
    \node[] at (-2.3,.9) {$T_0'$};
    \draw[->] (-1,-1.9) to [out=-10,in=-150] (1.4,-1);
    \node[] at (-1.3,-1.9) {$\hat{T_0}$};
    %Zylinder
    \draw[] (1.5,-1.5) -- (1.5,1.5);
    \draw[] (3.5,-1.5) -- (3.5,1.5);
    \begin{scope}[canvas is zx plane at y=0]
    \draw (0,2.5) circle (2cm);
    \draw[fill=gray,opacity=0.5] (0,2.5) circle (1cm);
    %
    \draw[->] (-2,0) -- (3,0);
    \end{scope}

    \begin{scope}[canvas is zx plane at y=1.5]
    \draw (0,2.5) circle (1cm);
    \end{scope}

    \begin{scope}[canvas is zx plane at y=-1.5]
    \draw (0,2.5) circle (1cm);
    \end{scope}     

    \begin{scope}[every node/.append style={
        xslant=1,sloped}
    ]    
    \node at (2.4,-.2) {\scalebox{1}[.7]{$T_0$}};
    \node at (4,.4) {\scalebox{1}[.7]{$T$}};
    \node at (-.8,-.2) {\scalebox{1}[.7]{$\mathbb{R}^n$}};
    \end{scope}

    \draw[] (6,-2) to [out=20,in=160] (11,-2.5);
    \draw[] (11,-2.5) to [out=90,in=220] (13,2.5);
    \draw[] (13,2.5) to [out=-200,in=10] (8,3.5);

    \draw[] (7,-.5) to [out=20,in=160] (10,-1);
    \draw[] (10,-1) to [out=90,in=220] (11,1.8);
    \draw[] (11,1.8) to [out=-200,in=10] (8.5,2.5);
    \draw[] (8.5,2.5) to [out=-150,in=100] (7,-.5);     

    \fill[cyan,fill opacity=0.4] (7.5,.7) to [out=0,in=140] (9,0.2)
    to [out=70,in=240] (9.8,1.4)
    to [out=160,in=0] (8.3,1.8)
    to [out=-150,in=70] cycle;
    \draw[] (7.5,.7) to [out=0,in=140] (9,0.2)
    to [out=70,in=240] (9.8,1.4);
    \draw[dashed] (9.8,1.4) to [out=160,in=0] (8.3,1.8)
    to [out=-150,in=70] (7.5,.7);


    \draw[] (9,.2) -- (9,1.3);
    \draw[] (7.5,.7) -- (7.5,1.8);
    \draw[] (9.8,1.4) -- (9.8,2.5);
    \draw[] (8.3,1.8) -- (8.3,2.9);

    \draw[] (7.5,1.8) to [out=0,in=140] (9,1.3);
    \draw[] (9,1.3) to [out=70,in=240] (9.8,2.5);
    \draw[] (9.8,2.5) to [out=160,in=0] (8.3,2.9);
    \draw[] (8.3,2.9) to [out=-150,in=70] (7.5,1.8);

    \draw[dashed] (9,.2) -- (9,-.9);
    \draw[dashed] (7.5,.7) -- (7.5,-.4);
    \draw[dashed] (9.8,1.4) -- (9.8,.3);
    \draw[dashed] (8.3,1.8) -- (8.3,.7);        

    \draw[dashed] (7.5,-.4) to [out=0,in=140] (9,-0.9);
    \draw[dashed] (9,-.9) to [out=70,in=240] (9.8,.3);
    \draw[dashed] (9.8,.3) to [out=160,in=0] (8.3,.7);
    \draw[dashed] (8.3,.7) to [out=-150,in=70] (7.5,-.4);
    \end{tikzpicture}

\end{document}
  • Oh my this was fast and exactly what I was looking for! Thanks a lot for your help Gonzalo! One question though, is the 3D that tikz generates correct? It looks a bit odd on the sides ofe the cylinder for example with the intersection of the circles with the straight up going bars. – Michael A Sep 9 '15 at 23:34
  • @MichaelA Yes, the cylinder looks odd. Perhaps you can open a new question asking for better ways to draw it? – Gonzalo Medina Sep 9 '15 at 23:42
  • That looks like something you’d do witn pgfplots. – Davislor Sep 10 '15 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.