3

enter image description here

I am trying to make this tikzpicture using the answer from Drawing manifolds in tikz but I can not make the intersection of U and V gray. If I make U and V white then the intersection would be white too. My question is how can I make the intersection gray and keeping everything else white ?

\documentclass[border=5mm,tikz]{standalone}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\usetikzlibrary{patterns, positioning, arrows}
\pgfplotsset{compat=1.15}

\begin{document} \begin{figure}[h] \centering \begin{tikzpicture}

% Functions i \path[->] (0.8, 0) edge [bend right] node[left, xshift=-2mm] {$\varphi$} (-1, -2.9); \draw[white,fill=white] (0.06,-0.57) circle (.15cm);

% Functions j \path[->] (4.2, 0) edge [bend left] node[right, xshift=2mm] {$\psi$} (6.2, -2.8); \draw[white, fill=white] (4.54,-0.12) circle (.15cm);

% Manifold \draw[smooth cycle] plot coordinates{(2,2) (-0.5,0) (3,-2) (5,1)} node at (3,2.3) {$M$};

% Help lines %\draw[help lines] (-3,-6) grid (8,6);

% Subsets \draw[smooth cycle, dashed] plot coordinates {(1,0) (1.5, 1.2) (2.5,1.3) (2.6, 0.4)} node [label={[label distance=-0.3cm, xshift=-2cm, fill=white]:$U$}] {}; \draw[smooth cycle, dashed] plot coordinates {(4, 0) (3.7, 0.8) (3.0, 1.2) (2.5, 1.2) (2.2, 0.8) (2.3, 0.5) (2.6, 0.3) (3.5, 0.0)} node [label={[label distance=-0.8cm, xshift=.75cm, yshift=1cm, fill=white]:$V$}] {};

% First Axis \draw[thick, ->] (-3,-5) -- (0, -5) {}; \draw[thick, ->] (-3,-5) -- (-3, -2) {};

% Arrow from i to j \path[->] (0, -3.85) edge [bend left] node[midway, above]{$\psi_{ij}$} (4.5, -3.85);

% Second Axis \draw[thick, ->] (5, -5) -- (8, -5) node [label=above:$\phi_j(U_j)$] {}; \draw[thick, ->] (5, -5) -- (5, -2) node [label=right:$\mathbb{R}^m$] {};

% Sets in R^m \draw[white] (-0.67, -3.06) -- +(180:0.8) arc (180:270:0.8); \fill[even odd rule, white] [smooth cycle] plot coordinates{(-2, -4.5) (-2, -3.2) (-0.8, -3.2) (-0.8, -4.5)} (-0.67, -3.06) -- +(180:0.8) arc (180:270:0.8); \draw[smooth cycle, dashed] plot coordinates{(-2, -4.5) (-2, -3.2) (-0.8, -3.2) (-0.8, -4.5)}; \draw [dashed] (-1.45, -3.06) arc (180:270:0.8);

\draw[white] (5.7, -3.06) -- +(-90:0.8) arc (-90:0:0.8); \fill[even odd rule, white] [smooth cycle] plot coordinates{(7, -4.5) (7, -3.2) (5.8, -3.2) (5.8, -4.5)} (5.7, -3.06) -- +(-90:0.8) arc (-90:0:0.8); \draw[smooth cycle] plot coordinates{(7, -4.5) (7, -3.2) (5.8, -3.2) (5.8, -4.5)}; \draw (5.69, -3.85) arc (-90:0:0.8);

\end{tikzpicture} \end{figure} \end{document}

endeavor
  • 133

1 Answers1

1

You can use the \clip command to clip all subsequent drawing. That's how it works. Note that I have removed all unnecessary packages.

    \documentclass[border=5mm]{standalone}
    \usepackage {tikz}
    \usepackage{amssymb}
\begin{document}
\begin{tikzpicture}

% Functions i
\path[->] (0.8, 0) edge [bend right] node[left, xshift=-2mm] {$\varphi$} (-1, -2.9);
\draw[white,fill=white] (0.06,-0.57) circle (.15cm);

% Functions j
\path[->] (4.2, 0) edge [bend left] node[right, xshift=2mm] {$\psi$} (6.2, -2.8);
\draw[white, fill=white] (4.54,-0.12) circle (.15cm);

% Manifold
\draw[smooth cycle] plot coordinates{(2,2) (-0.5,0) (3,-2) (5,1)} node at (3,2.3) {$M$};

% Subsets
\begin{scope}
    \clip[smooth cycle] plot coordinates {(1,0) (1.5, 1.2) (2.5,1.3) (2.6, 0.4)};
    \fill[gray!50, smooth cycle] plot coordinates {(4, 0) (3.7, 0.8) (3.0, 1.2) (2.5, 1.2) (2.2, 0.8) (2.3, 0.5) (2.6, 0.3) (3.5, 0.0)};
\end{scope}
\draw[dashed, smooth cycle] plot coordinates {(1,0) (1.5, 1.2) (2.5,1.3) (2.6, 0.4)}
node [label={[label distance=-0.3cm, xshift=-2cm, fill=white]:$U$}] {};
\draw[dashed, smooth cycle] plot coordinates {(4, 0) (3.7, 0.8) (3.0, 1.2) (2.5, 1.2) (2.2, 0.8) (2.3, 0.5) (2.6, 0.3) (3.5, 0.0)} node [label={[label distance=-0.8cm, xshift=.75cm, yshift=1cm, fill=white]:$V$}] {};

% First Axis
\draw[thick, ->] (-3,-5) -- (0, -5)  {};
\draw[thick, ->] (-3,-5) -- (-3, -2)  {};

% Arrow from i to j
\path[->] (0, -3.85) edge [bend left]  node[midway, above]{$\psi_{ij}$} (4.5, -3.85);

% Second Axis
\draw[thick, ->] (5, -5) -- (8, -5) node [label=above:$\phi_j(U_j)$] {};
\draw[thick, ->] (5, -5) -- (5, -2) node [label=right:$\mathbb{R}^m$] {};

% Sets in R^m \begin{scope} \clip [smooth cycle] plot coordinates{(-2, -4.5) (-2, -3.2) (-0.8, -3.2) (-0.8, -4.5)}; \draw[fill=gray!50, dashed] (-0.8, -3.2) circle (0.8); \end{scope} \draw [smooth cycle, dashed] plot coordinates{(-2, -4.5) (-2, -3.2) (-0.8, -3.2) (-0.8, -4.5)};

\begin{scope} \clip [smooth cycle] plot coordinates{(7, -4.5) (7, -3.2) (5.8, -3.2) (5.8, -4.5)}; \draw[fill=gray!50, dashed] (5.8, -3.2) circle (0.8); \end{scope} \draw[smooth cycle,dashed] plot coordinates{(7, -4.5) (7, -3.2) (5.8, -3.2) (5.8, -4.5)}; \end{tikzpicture}

\end{document}

enter image description here

kabenyuk
  • 604