Suppose I have an infinite unbounded set of complex numbers, for example all the numbers outside the unit circle. Is there some good way to visualize that set using LaTeX with some drawing library?
Asked
Active
Viewed 1,530 times
1 Answers
11
A common practice is to use some kind of filling for the region, either in the form of shading or some type of pattern.
One option using pgfplots:
The code:
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,
y=1cm,
axis lines=middle,
axis background/.style={
shade,
inner color=blue!18,
outer color=blue!2,
},
xmin=-4,
xmax=4,
ymin=-4,
ymax=4,
xtick={-3,...,3},
ytick={-3,...,3},
axis on top
]
\addplot[no marks] coordinates {(0,0)};
\draw[fill=white,dashed] (axis cs:0,0) circle [radius=1cm];
\end{axis}
\end{tikzpicture}
\end{document}
And a "pure" TikZ version:
The code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\fill[shade,inner color=blue!18,outer color=blue!2]
(-4,-4) rectangle (4,4);
\draw[fill=white,dashed] (0,0) circle [radius=1cm];
\draw[-latex]
(-4,0) -- (4,0);
\draw[-latex]
(0,-4) -- (0,4);
\foreach \Valor in {-3,-2,-1,1,2,3}
{
\draw ([yshift=1.5pt]\Valor,0) -- ([yshift=-1.5pt]\Valor,0) node[below,font=\footnotesize] {$\Valor$};
\draw ([xshift=-1.5pt]0,\Valor) -- ([xshift=1.5pt]0,\Valor) node[left=3pt,font=\footnotesize] {$\Valor$};
}
\end{tikzpicture}
\end{document}
If you opt for using patterns, here's some example in both pgfplots and TikZ versions (but I'd suggest using the previous approach):
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=1cm,
y=1cm,
axis lines=middle,
axis background/.style={
opacity=0.5,
pattern=north west lines
},
xmin=-4,
xmax=4,
ymin=-4,
ymax=4,
xtick={-3,...,3},
ytick={-3,...,3},
axis on top
]
\addplot[no marks] coordinates {(0,0)};
\draw[fill=white,dashed] (axis cs:0,0) circle [radius=1cm];
\end{axis}
\end{tikzpicture}\par\bigskip
\begin{tikzpicture}
\fill[pattern=north west lines,opacity=0.5]
(-4,-4) rectangle (4,4);
\draw[fill=white,dashed] (0,0) circle [radius=1cm];
\draw[-latex]
(-4,0) -- (4,0);
\draw[-latex]
(0,-4) -- (0,4);
\foreach \Valor in {-3,-2,-1,1,2,3}
{
\draw ([yshift=1.5pt]\Valor,0) -- ([yshift=-1.5pt]\Valor,0) node[below,font=\footnotesize] {$\Valor$};
\draw ([xshift=-1.5pt]0,\Valor) -- ([xshift=1.5pt]0,\Valor) node[left=3pt,font=\footnotesize] {$\Valor$};
}
\end{tikzpicture}
\end{document}
Gonzalo Medina
- 505,128
-
+1 It might be nicer to have the shading fade with the absolute value of the vectors. – moewe Sep 11 '15 at 16:38
-
-



!in the markdown code for the image.) – Torbjørn T. Sep 11 '15 at 16:31