# Styled or fixed color line-segments in PGF

When I want to plot coordinate data, I know that I can color individual scatter points using defined colors using point meta=explicit. The line segments between two points seem to be colored by an averaged color of the two endpoints.

1) Can I force the color of the line segments to be either the same as the start or endpoints (rather than an averaged color)

2) For black/white plots different gray shades are sometimes hard to distinguish. Is it possible to give the line segments individual styles (i.e. dashed, dotted).

Some background: I want to plot a decreasing curve where different segments represent different phases that need to be distinguishable.

-

You can tell PGFplots to use the color of one of the end points of the line segments, instead of the average, by setting shader=flat corner (instead of the default shader=flat, which averages the values). In a 2D plot, the line will have the color of the previous point, but in a 3D plot, it is not defined which point influences the line colour, so you would have to be a bit careful in that case.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scatter, % To colour the points
point meta=explicit, % To be able to specify the column for the colours
shader=flat corner % To use the color of one point for the line segment
]
mesh,   % Colour the lines
thick
] table [meta=phase] {
time value phase
1 5 1
3 15 2
7 14 3
10 7 3
12 1 3
};
\end{axis}
\end{tikzpicture}
\end{document}

-
How can I add such a plot to the legend with the marker as icon (instead of the default tiny mesh symbol)? I created a question for that -> tex.stackexchange.com/questions/33535/… –  dcn Nov 3 '11 at 11:37