Segmentos de curvas suaves

Segmentos de curvas suaves

Necesito que el último segmento de la curva (que está discontinuo) esté conectado suavemente con el segmento anterior. ¡Sugiera también otras mejoras!

\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}

ingrese la descripción de la imagen aquí

Respuesta1

Simplemente dibuje el gráfico dos veces, una sólida y otra discontinua, y recorte el dominio objetivo para cada una.

\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}

ingrese la descripción de la imagen aquí

información relacionada