5

I'm trying to use tikz to draw a line that changes color at two different points. As you can see from the code below, what I want is a line that starts solid red, changes to dotted gray, and ends as solid green. When I compile, though, I get the red section only, without the other two. What is the remedy?

\documentclass[border=2mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

    %% The line itself

    \draw [red, very thick, |-] (0,0) -- (22,0);
    \draw [gray, very thick, dotted] (22,0 -- 26,0);
    \draw [green, very thick, ->] (26,0 -- 40,0);

\end{tikzpicture}
\end{document}

closed as off-topic by Torbjørn T., Andrew Swann, Stefan Pinnow, Schweinebacke, egreg Apr 1 '17 at 10:51

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Write (22,0) -- (26,0) instead of (22,0 -- 26,0), and (26,0) -- (40,0) instead of (26,0 -- 40,0). – jubobs Jun 26 '14 at 20:30
  • 1
    ...And this is why it's a bad idea to code when you're tired. I can't believe I did that. – crmdgn Jun 26 '14 at 20:36
  • 2
    This question appears to be off-topic because it was solved by correcting a simple typo. – Paul Gessler Jun 26 '14 at 23:04
  • 5
    This question appears to be off-topic because it was solved by correcting a simple typo. – Masroor Jun 26 '14 at 23:29
  • 4
    I'm voting to close this question as off-topic because the problem was caused by a typo (forgetting a couple of parentheses). – Torbjørn T. Apr 1 '17 at 9:25

Browse other questions tagged or ask your own question.