Tikz: Is it possible to change line style within same \draw command?

You can't have multiple line styles within the same path. You can insert square brackets pretty much anywhere on a path to change options, but most of them will then affect the entire path.

One way out is using the edge operation, which is similar to a node in that it is actually a separate path:

\draw[style1] (0,0) -- ++(1,0) edge[style2] ++(1,0);

This works fine for straight lines and basic curves (try bend left, in angle and out angle as options in style2).

Adding to Jens Polz's answer, I would suggest using the coordinate operation instead of node: using it, you don't need to provide empty node contents and you also don't get gaps in your path:

\draw[style1] (0,0) -- ++( 1,0) coordinate (x);
\draw[style2] (x)   -- ++( 0,1) coordinate (x);
\draw[style3] (x)   -- ++(-1,0);

It's possible to re-use the same name for this temporary coordinate.


I am not quite sure, if you can change the style within a plotting command, so I would be interested in an answer to your question myself. However, to not loose the relative coordinates, you can do the following. By placing and naming a node at the last coordinate of your plotting command, you can call it in the next one, without loosing your relative coordinates:

\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}
  \draw[thick] (0,1) -- ++ (1,0) -- ++ (4,2) -- ++ (1,1) node(A)[inner sep=0]{};
  \draw[thick, dashed] (A) -- ++ (-2,0) -- ++ (0,-2) node(B)[inner sep=0]{};
  \draw[thick] (B) -- ++ (2,0);
\end{tikzpicture}  
\end{document}