5

I've got a problem, I've tried it a lot and I've investigated about it but I haven't found the answer.

I've got a code like this....

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
  \draw[very thick, latex-] (0,8) -- (0,1);
  \draw[very thick] decorate [decoration={zigzag}] {(0,1) -- (0,0)};
  \draw[very thick, -latex] (0,0) -- (14,0);
\end{tikzpicture}
\end{document}

enter image description here

And I want to do a full \draw or \path joining the first \draw with the second one (the one with decoration) and the third, so the upper line connects with the zigzaged one at (0,1), then draw the decorated line and then at (0,0) connect this line with the other.

I would really appreciate the ideas.

9

TikZ

You can decorate only one part of the path.

Code

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
  \draw[very thick,latex-latex,decoration={zigzag}]
                                               (0,8) -- (0,1) decorate {-- (0,0)} -- (14,0);
\end{tikzpicture}

Output

TikZ solution

Detail:
Tikz solution: detail

pgfplots

As cmhughes already commented, you might be interested in the pgfplots package. The following example is taken from the manual.

Code

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis x line=bottom,
    axis y line=center,
    tick align=outside,
    axis y discontinuity=crunch,
    ymin=95, enlargelimits=false
]
    \addplot[
        blue,
        mark=none,
        domain=-4:4,
        samples=20
    ]
    { x*x+x+104 };
\end{axis}
\end{tikzpicture}
\end{document}

Output

pgfplots solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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