Glatte Kurvensegmente

Glatte Kurvensegmente

Ich brauche das letzte Segment der Kurve (gestrichelt), das reibungslos mit dem vorherigen Segment verbunden ist. Bitte schlagen Sie auch andere Verbesserungen vor!

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin {axis}[
    height=5cm, width=12cm,
    xmin=-6, xmax=21, ymin=0, ymax=6, 
   xlabel={}, 
    ylabel={trade effect}, 
    ylabel style={align=center}, 
    axis x line=bottom, axis y line = left, 
    axis line style={-latex, thick},
    xticklabels={,,}, yticklabels={,,},
    ytick=\empty,
    xtick={-5,0,5,10,15},
    xticklabels={$t_{a}$,$t_{b}$,$t_{c}$,$t_{d}$,$t_{e}$},
    ]
\addplot [mark=none, line width=.8pt, smooth]coordinates {
    (-5,0) (0,1)(5,4) (10,5) (15,5)};
\addplot[mark=none, line width=.8pt, smooth, dashed] coordinates {
    (15,5) (20,4)};
\addplot[mark=none, dashed] coordinates {(0,0) (0,6)};
\addplot[mark=none, dashed] coordinates {(5,0) (5,6)};
\addplot[mark=none, dashed] coordinates {(10,0) (10,6)};
\addplot[mark=none, dashed] coordinates {(15,0) (15,6)};
\end{axis}
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

Antwort1

Zeichnen Sie das Diagramm einfach zweimal, einmal durchgezogen und einmal gestrichelt, und schneiden Sie jedes Mal die Zieldomäne aus.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin {axis}[
    height=5cm, width=12cm,
    xmin=-6, xmax=21, ymin=0, ymax=6, 
   xlabel={}, 
    ylabel={trade effect}, 
    ylabel style={align=center}, 
    axis x line=bottom, axis y line = left, 
    axis line style={-latex, thick},
    xticklabels={,,}, yticklabels={,,},
    ytick=\empty,
    xtick={-5,0,5,10,15},
    xticklabels={$t_{a}$,$t_{b}$,$t_{c}$,$t_{d}$,$t_{e}$},
    ]
\begin{scope}   
\clip (\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymin})
 rectangle (15,\pgfkeysvalueof{/pgfplots/ymax});
\addplot [mark=none, line width=.8pt, smooth] coordinates {
    (-5,0) (0,1)(5,4) (10,5) (15,5) (20,4)};
\end{scope} 
\begin{scope}   
\clip (15,\pgfkeysvalueof{/pgfplots/ymin})
 rectangle (\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\addplot [mark=none, line width=.8pt, smooth,dashed] coordinates {
    (-5,0) (0,1)(5,4) (10,5) (15,5) (20,4)};
\end{scope} 
\addplot[mark=none, dashed] coordinates {(0,0) (0,6)};
\addplot[mark=none, dashed] coordinates {(5,0) (5,6)};
\addplot[mark=none, dashed] coordinates {(10,0) (10,6)};
\addplot[mark=none, dashed] coordinates {(15,0) (15,6)};
\end{axis}
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen