Usando el siguiente código de la respuesta aesta pregunta
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.8, transform shape, -|/.style args={of #1 at #2}{insert path={(intersection cs:first line={#1}, second line={(#2,0)--(#2,10)}) coordinate (aux) (#2,0) |- (0,0|-aux) }}, vert/.style args={of #1 at #2}{insert path={(#2,0) -- (intersection cs:first line={#1}, second line={(#2,0)--(#2,10)}) }}]% this is used when drawing 2 lines to intersect with
\pgfmathsetmacro{\incrmnty}{1.}
\pgfmathsetmacro{\incrmntx}{2.}
\pgfmathsetmacro{\xlab}{2006}
\pgfmathsetmacro{\xn}{5}
\pgfmathsetmacro{\yn}{5}
\begin{scope}[xshift=0cm, yshift=0cm]
\draw [thick](0,0) -- (\incrmntx*\xn+\incrmntx*1,0);
\node at (\incrmntx*\xn+\incrmntx*1,\incrmnty*\yn-.4) (endx){};
\draw [thick](0,0) -- (0,\incrmnty*\yn);
\end{scope}
\begin{scope}[xshift=0cm, yshift=0cm]
\foreach \x [evaluate=\x as \aff using int(\xlab+(1*\x))] in {0,...,\xn}{\draw [black!40!white] (\incrmntx*\x+\incrmntx*.4,0) node [black, xshift=0cm, yshift=-.68cm, font=\footnotesize] {\aff} -- +(-90:.2);}
\end{scope}
\draw[blue!40!black, densely dashed, line width=.4mm] (-.1*\incrmntx,1.56*\incrmnty) node [black, left, yshift=-.06cm] {Intercept} -- (endx.center);
\draw[blue!80!white, thick, dashed, -|={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn+\incrmntx*.4}}] node [black, left, yshift=.06cm] {2011 value};
\draw[blue!80!white, thick, dashed, -|={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn-2+\incrmntx*.4}}] node [black, left, yshift=-.06cm] {2010 value};
\draw[blue!80!white, thick, dashed, vert={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn-4+\incrmntx*.4}}];
\draw[red!80!white, thick] (\incrmntx*\xn-7+\incrmntx*.4,2.58*\incrmnty) -- (\incrmntx*\xn-10+\incrmntx*.4,2.58*\incrmnty) node [black, xshift=.6cm, yshift=.3cm] {Slope} -- +(-90:.82cm);
\end{tikzpicture}
\end{frame}
\end{document}
Cómo realizar las siguientes modificaciones:
Modificar el estilo para dibujar solo una línea oblicua, en lugar de dos
Trazar la línea roja desde la intersección de la ubicación especificada con la línea oblicua (un punto entre 2007 y 2008) hasta la ubicación final especificada (en 2006)
Respuesta1
He aquí un estilo hat
para abordar el segundo punto. El primer punto, lamentablemente, no lo entiendo. ¿Qué quieres decir con "dibuja sólo una línea oblicua, en lugar de dos", es decir, a qué dos líneas te refieres?
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
\begin{tikzpicture}[scale=.8, transform shape,
-|/.style args={of #1 at #2}{insert path={(intersection cs:first line={#1}, second line={(#2,0)--(#2,10)}) coordinate (aux) (#2,0) |- (0,0|-aux) }},
vert/.style args={of #1 at #2}{insert path={(#2,0) -- (intersection cs:first
line={#1}, second line={(#2,0)--(#2,10)}) }},
hat/.style args={of #1 at #2 and #3}{insert path={%
(intersection cs:first line={#1}, second line={(#2,0)--(#2,10)}) |-
(intersection cs:first line={#1}, second line={(#3,0)--(#3,10)})
}}
]% this is used when drawing 2 lines to intersect with
\pgfmathsetmacro{\incrmnty}{1.}
\pgfmathsetmacro{\incrmntx}{2.}
\pgfmathsetmacro{\xlab}{2006}
\pgfmathsetmacro{\xn}{5}
\pgfmathsetmacro{\yn}{5}
\begin{scope}[xshift=0cm, yshift=0cm]
\draw [thick](0,0) -- (\incrmntx*\xn+\incrmntx*1,0);
\node at (\incrmntx*\xn+\incrmntx*1,\incrmnty*\yn-.4) (endx){};
\draw [thick](0,0) -- (0,\incrmnty*\yn);
\end{scope}
\begin{scope}[xshift=0cm, yshift=0cm]
\foreach \x [evaluate=\x as \aff using int(\xlab+(1*\x))] in {0,...,\xn}{\draw [black!40!white] (\incrmntx*\x+\incrmntx*.4,0) node [black, xshift=0cm, yshift=-.68cm, font=\footnotesize] {\aff} -- +(-90:.2);}
\end{scope}
\draw[blue!40!black, densely dashed, line width=.4mm] (-.1*\incrmntx,1.56*\incrmnty) node [black, left, yshift=-.06cm] {Intercept} -- (endx.center);
\draw[blue!80!white, thick, dashed, -|={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn+\incrmntx*.4}}] node [black, left, yshift=.06cm] {2011 value};
\draw[blue!80!white, thick, dashed, -|={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn-2+\incrmntx*.4}}] node [black, left, yshift=-.06cm] {2010 value};
\draw[blue!80!white, thick, dashed, vert={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)} at {\incrmntx*\xn-4+\incrmntx*.4}}];
\draw[red!80!white, thick,hat={of {(-.1*\incrmntx,1.56*\incrmnty)--(endx.center)}
at {\incrmntx*\xn-10+\incrmntx*.4} and {\incrmntx*\xn-7+\incrmntx*.4}}]
node[black,pos=0.55,above right]{Slope};
\end{tikzpicture}
\end{frame}
\end{document}