[Tex/LaTex] Hatching in a circle and outside a circle

tikz-pgf

I am trying to graph two circles on the same page so that the x-axes of both graphs are aligned and the y-axes of both graphs are the same height. (Maybe the appearance of these would not look nice with x-axes aligned.) The first circle is to have radius 3, and the second circle is to be dashed and to have radius 5/4; not to waste space, the scaling on the first graph is to be less than the scaling for the second graph. Maybe include five tick marks along axes a unit apart in first graph and three tick marks a half-a-unit apart in second graph. I would like diagonal hatching for shading. In the first graph, shading should be inside the circle, and in the second graph, shading should be outside the circle. (I looked on page 217 of tikzpgfmanual.pdf for drawing diagonal hatch lines. They are not there. Please indicate how to separate hatch lines.) I included some of the suggested code. I did not find a manual for including tick marks on the axes. When shading, do you usually include arrows on axes?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,angles,quotes}


\begin{document}


$\{(x, \, y) \mid \vert x^{2} + (y - 1)^{2} \vert \leq 3\}$ \\
\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt}]
  \draw[<->] (-4,0) -- (4,0) node[below] {$x$};
  \draw[<->] (0,-3) -- (0,5) node[left] {$y$};
\end{tikzpicture}


$\{(x, \, y) \mid x^{2} + y^{2} > 5/4\}$ \\
\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt}]
  \draw[<->] (-2,0) -- (2,0) node[below] {$x$};
  \draw[<->] (0,-2) -- (0,2) node[left] {$y$};
\end{tikzpicture}


\end{document}

Best Answer

Is it something like this what you want to achieve?

enter image description here

The code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{patterns}

\newcommand\drawticks[1]{
\foreach \Valor in {-#1,...,#1}
  {
  \draw ([yshift=2pt]\Valor,0) -- ([yshift=-2pt]\Valor,0);  
  \draw ([xshift=2pt]0,\Valor) -- ([xshift=-2pt]0,\Valor);  
  }
}

\begin{document}

\begin{center}
\begin{tikzpicture}[
dot/.style={
  fill,
  circle,
  inner sep=1pt
  }
]
\begin{scope}[x=0.4cm,y=0.4cm]
\draw[<->] 
  (-5,0) -- (5,0) node[below] {$x$};
\draw[<->] 
  (0,-5) node (yaxisl1) {} -- (0,5) node[left] {$y$};
\fill[pattern=north west lines,opacity=.6,draw] 
  (0,1) circle [radius=3];
\node[anchor=north] 
  at (yaxisl1.south) 
  (label1)
  {$\{(x, \, y) \mid \vert x^{2} + (y - 1)^{2} \vert \leq 3\}$};
\drawticks{4}
\node[dot,label={left:$(0,1)$}]
  at (0,1) {};
\draw[thin] 
  (0,1) -- node[below] {3} ++(45:3);
\end{scope}

\begin{scope}[xshift=7cm]
\clip
  (-2.2,-2) rectangle (2.2,2.2);
\fill[pattern=north west lines,opacity=0.6]
  (current bounding box.north west)
  rectangle
  (current bounding box.south east);
\end{scope}
\begin{scope}[xshift=7cm]
\draw[dashed,fill=white] (0,0) circle [radius=5/4];
\draw[<->] (-2,0) -- (2,0) node[below] {$x$};
\draw[<->] (0,-2) node (yaxisl2) {} -- (0,2) node[left] {$y$};
\node[anchor=north] 
  at (yaxisl2.south|-yaxisl1.south) 
  {$\{(x, \, y) \mid x^{2} + y^{2} > 5/4\}$};
\drawticks{1}
\node[dot]
  at (0,0) {};
\draw[thin] 
  (0,0) -- node[above] {$\frac{5}{4}$} ++(45:5/4);
\end{scope}
\end{tikzpicture}
\end{center}

\end{document}