4

my friends, I want to draw a picture like this:

ellipse

My MWE is here:

\documentclass[12pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
 
\usetikzlibrary[patterns]

\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4.3,-11.42) rectangle (21.78,6.3);
\fill[line width=2.8pt,color=black,fill=black,pattern=north east lines,pattern color=white] (4.,-1.) -- (4.,-7.) -- (16.,-7.) -- (16.,-1.) -- cycle;
\draw [line width=2.8pt,color=black] (4.,-1.)-- (4.,-7.);
\draw [line width=2.8pt,color=black] (4.,-7.)-- (16.,-7.);
\draw [line width=2.8pt,color=black] (16.,-7.)-- (16.,-1.);
\draw [line width=2.8pt,color=black] (16.,-1.)-- (4.,-1.);
\draw [rotate around={0.:(10.,-4.)},line width=2.pt] (10.,-4.) ellipse (3.7022649707724398cm and 2.169508219345722cm);
\draw [line width=2.pt] (8.,-1.)-- (8.,-7.);
\draw [line width=2.pt] (12.,-7.)-- (12.,-1.);
\draw [line width=2.pt] (4.,-1.)-- (4.,-7.);
\draw [line width=2.pt] (4.,-7.)-- (16.,-7.);
\draw [line width=2.pt] (16.,-7.)-- (16.,-1.);
\draw [line width=2.pt] (16.,-1.)-- (4.,-1.);
\draw (5.5,-0.04) node[anchor=north west] {$B_1$};
\draw (9.62,-0.04) node[anchor=north west] {$B_2$};
\draw (13.88,-0.04) node[anchor=north west] {$B_3$};
\draw (15.35,-1) node[anchor=north west] {$\Omega$};
\begin{scriptsize}
\draw [fill=black] (4.,-1.) circle (2.5pt);
\draw [fill=black] (4.,-7.) circle (2.5pt);
\draw [fill=black] (16.,-7.) circle (2.5pt);
\draw [fill=black] (16.,-1.) circle (2.5pt);
\draw [fill=black] (8.,-1.) circle (2.0pt);
\draw [fill=black] (8.,-7.) circle (2.0pt);
\draw [fill=black] (12.,-7.) circle (2.0pt);
\draw [fill=black] (12.,-1.) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

\end{document}

which renders this:

ellipse not cross-hatched

Can anyone help me with the cross hatching? Thanks in advance!

1
  • Aside: That's "hatching", not "cross-hatching". (In fact, it would probably look better - easier on the eyes and easier to discern the "two" patterns - if one was cross-hatched and the other simply hatched.)
    – MrWhite
    Feb 28, 2022 at 12:34

1 Answer 1

7
\documentclass[12pt]{standalone}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.18}
\usepackage{tikz}
%\usepackage{mathrsfs}
\usetikzlibrary{arrows}
%\pagestyle{empty}
 
\usetikzlibrary{patterns.meta}

\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
%\clip(-4.3,-11.42) rectangle (21.78,6.3);
%\fill[line width=2.8pt,color=black,fill=black,pattern=north east lines,pattern color=white] (4.,-1.) -- (4.,-7.) -- (16.,-7.) -- (16.,-1.) -- cycle;
\draw [line width=2.8pt,color=black] (4.,-1.)-- (4.,-7.);
\draw [line width=2.8pt,color=black] (4.,-7.)-- (16.,-7.);
\draw [line width=2.8pt,color=black] (16.,-7.)-- (16.,-1.);
\draw [line width=2.8pt,color=black] (16.,-1.)-- (4.,-1.);
\begin{scope}
\clip (4,-1)rectangle(8,-7);
\draw [pattern={Lines[angle=-45,distance=6pt,line width=1pt]},rotate around={0.:(10.,-4.)},line width=2.pt] (10.,-4.) ellipse (3.7022649707724398cm and 2.169508219345722cm);
\end{scope}
\begin{scope}
\clip (8,-1)rectangle(12,-7);
\draw [pattern={Lines[angle=45,distance=6pt,line width=1pt]},rotate around={0.:(10.,-4.)},line width=2.pt] (10.,-4.) ellipse (3.7022649707724398cm and 2.169508219345722cm);
\end{scope}
\begin{scope}
\clip (12,-1)rectangle(16,-7);
\draw [pattern={Lines[angle=-45,distance=6pt,line width=1pt]},rotate around={0.:(10.,-4.)},line width=2.pt] (10.,-4.) ellipse (3.7022649707724398cm and 2.169508219345722cm);
\end{scope}
\draw [line width=2.pt] (8.,-1.)-- (8.,-7.);
\draw [line width=2.pt] (12.,-7.)-- (12.,-1.);
%\draw [line width=2.pt] (4.,-1.)-- (4.,-7.);
%\draw [line width=2.pt] (4.,-7.)-- (16.,-7.);
%\draw [line width=2.pt] (16.,-7.)-- (16.,-1.);
%\draw [line width=2.pt] (16.,-1.)-- (4.,-1.);
\draw (5.5,-0.04) node[anchor=north west] {$B_1$};
\draw (9.62,-0.04) node[anchor=north west] {$B_2$};
\draw (13.88,-0.04) node[anchor=north west] {$B_3$};
\draw (15.35,-1) node[anchor=north west] {$\Omega$};
\begin{scriptsize}
\draw [fill=black] (4.,-1.) circle (2.5pt);
\draw [fill=black] (4.,-7.) circle (2.5pt);
\draw [fill=black] (16.,-7.) circle (2.5pt);
\draw [fill=black] (16.,-1.) circle (2.5pt);
\draw [fill=black] (8.,-1.) circle (2.0pt);
\draw [fill=black] (8.,-7.) circle (2.0pt);
\draw [fill=black] (12.,-7.) circle (2.0pt);
\draw [fill=black] (12.,-1.) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

\end{document}

Some enhancement...

\documentclass[12pt]{standalone}
%\usepackage{pgfplots}
%\pgfplotsset{compat=1.18}
\usepackage{tikz}
%\usepackage{mathrsfs}
\usetikzlibrary{arrows}
%\pagestyle{empty}
 
\usetikzlibrary{patterns.meta}

\begin{document}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]

\coordinate(A1) at(4,-1);
\coordinate(A2) at(8,-1);
\coordinate(A3) at(12,-1);
\coordinate(A4) at(16,-1);

\coordinate(C1) at(4,-7);
\coordinate(C2) at(8,-7);
\coordinate(C3) at(12,-7);
\coordinate(C4) at(16,-7);

\begin{scope}[line width=2.8pt,color=black] 
\draw (A1) rectangle (C4);
\draw [save path=\ellipse] (10.,-4.) ellipse (3.70cm and 2.17cm);

\begin{scope}[line width=1pt]
\clip (A1)rectangle(C2);
\path[pattern={Lines[angle=-45,distance=6pt,line width=1pt]}] [use path=\ellipse];
\end{scope}
\begin{scope}
\clip (A2)rectangle(C3);
\path [pattern={Lines[angle=45,distance=6pt,line width=1pt]}] [use path=\ellipse];
\end{scope}
\begin{scope}
\clip (A3)rectangle(C4);
\path [pattern={Lines[angle=-45,distance=6pt,line width=1pt]}] [use path=\ellipse];
\end{scope}
\draw (A2)-- (C2);
\draw (A3)-- (C3);
\end{scope}
\path[every node/.style={above=3mm}](A1)--node{$B_1$}
                (A2)--node{$B_2$}
                (A3)--node{$B_3$}(A4);
                
\draw (A4) node[anchor=north east] {$\Omega$};

\foreach \i in{A,C}{
\foreach \j in{1,4}{
\filldraw(\i\j)circle[radius=2.5pt];}
\foreach \j in{2,3}{
\filldraw(\i\j)circle[radius=2pt];}}


\end{tikzpicture}

\end{document}

enter image description here

2
  • One can use arcs instead of clips, but this version is simpler. Feb 27, 2022 at 21:52
  • @JohnKormylo that's right! Feb 27, 2022 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .