Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to draw three graphs like these ones below:

enter image description here

Is there an easy way to draw these dashed areas?

This is what I have so far: enter image description here

from the following code:

\documentclass[11pt]{article}

\usepackage{tikz}

\begin{document}

Damping:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);

\foreach \x in {-4,-3,-2,-1,0,1}
    \draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
    \draw (1.5pt,\y cm) -- (-1.5pt,\y cm);

    \draw[thick,red] (0,0)--(-4,4);
    \draw[thick,red] (0,0)--(-4,-4);
\end{tikzpicture}

Settling Time:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);

\foreach \x in {-4,-3,-2,-1,0,1}
    \draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
    \draw (1.5pt,\y cm) -- (-1.5pt,\y cm);

    \draw[thick,blue] (-1,-4)--(-1,4);
\end{tikzpicture}

Frequency:\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);

\foreach \x in {-4,-3,-2,-1,0,1}
    \draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
    \draw (1.5pt,\y cm) -- (-1.5pt,\y cm);

    \draw[thick,orange] (-4,4)--(1,4);
\draw[thick,orange] (-4,-4)--(1,-4);
\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

TikZ offers you a library named patterns. To use it you need \usetikzlibrary{patterns} in your preamble.

In your case for the first case you can do

\begin{tikzpicture}[scale=0.6]
\draw[->] (-4.5,0) -- (1.5,0);
\draw[->] (0,-4.5) -- (0,4.5);
\foreach \x in {-4,-3,-2,-1,0,1}
    \draw (\x cm,1.5pt) -- (\x cm,-1.5pt);
\foreach \y in {-4,-3,-2,-1,0,1,2,3,4}
    \draw (1.5pt,\y cm) -- (-1.5pt,\y cm);
    \draw[thick,red,pattern=north east lines,pattern color=red] (-4,-4) -- (0,0)--(-4,4);
\end{tikzpicture}

enter image description here

So the key is to have more or less a defined surface. For case #2 and #3, \fill[pattern=north west lines] (0,1) rectangle (2,2); with adapted coordinates would work.

Of course there are more defined patterns if you refer to the manual (http://www.ctan.org/pkg/pgf).

share|improve this answer
    
Exactly what I was looking for! Thank you! –  Nicolai Anton Lynnerup Jun 9 at 7:17
    
@NicolaiAntonLynnerup if the answer is fine click on the thick to accept the answer, so that it can be closed –  s__C Jun 9 at 7:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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