9

I have the following MWE graph:

\documentclass{memoir}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {
    (1000,1)
    (1100,1.3589)
    (1200,2.5248)
    (1300,4.0476)
    (1400,7.9426)
    (1500,13.032)
    (1600,18.165)
    (1700,20.775)
};
\end{axis}
\end{tikzpicture}
\end{document}

I want to make the line turn into a dashed line after the 1400 point. This is similar to this question but I want to supply my own data. How can I change style in the middle of an addplot?

bombcar
  • 1,512
  • 10
  • 20
  • Can you add the coordinates in two sets and add the [dashed] option to the second set? – Thruston Apr 11 '14 at 17:37
  • How would I keep the line the same style? In my actual graph I am using cycle list name=black white – bombcar Apr 11 '14 at 17:47
  • It would be an easy task with more \addplots. We could add map with just only two colors (colormap), we could use scatter plot type, but that wouldn't solve your question. – Malipivo Apr 11 '14 at 19:55

1 Answers1

8

I'm probably not satisfying the question, but it's rather an easy task with more \addplot commands in use, we only need to split up the data and preserve one common point for two consecutive sets - it is (1400,7.9426) point in this example. This approach works with two (as in this example) or even more separations.

%! *latex mal-tikz-graph.tex
\documentclass{memoir}
\pagestyle{empty}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {
    (1000,1)
    (1100,1.3589)
    (1200,2.5248)
    (1300,4.0476)
    (1400,7.9426)
    };
\addplot[no marks, dashed, red, line width=2pt] coordinates {
    (1400,7.9426)
    (1500,13.032)
    (1600,18.165)
    (1700,20.775)
    };
\end{axis}
\end{tikzpicture}
\end{document}

mwe

Malipivo
  • 13,287