Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following code the dashed line that intersects with the y-axis is out of place and I don't know where I'm making the mistake (if there is any):

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{intersections,calc}

\begin{document}

\begin{tikzpicture}
    \draw [<->] (0,5) node (ejey) [left]{$\omega$} |- (5.5,0)  node (ejex)
    [right]{$l$};
    \draw [name path = ls] (0.5,0.5) coordinate (a) -- (4.5,4.5) node
    (b) [right] {$l^{s}(\omega, r)$};
    \draw [name path = ld] (0.5,4.5) coordinate (c) -- (4.5,0.5) node
    (d) [right] {$l^{d}(\omega)$};
    \path [name intersections={of=ls and ld, by=i}];
    \draw [dashed] (ejey |- i) node [left] {$\omega_{0}^{*}$} -| (i |- ejex)
    node [below] {$l_{0}^{*}$};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

The problem appears because your dashed line starts at the x-coordinate of the centre of the ejey node, that is at the centre of the omega. To make the line start flush with the axis, you can use

(ejey.east |- i)

instead of

(ejey |- i)

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{intersections,calc}

\begin{document}

\begin{tikzpicture}
    \draw [<->] (0,5) node (ejey) [left]{$\omega$} |- (5.5,0)  node (ejex) [right]{$l$};
    \draw [name path = ls] (0.5,0.5) coordinate (a) -- (4.5,4.5) node (b) [right] {$l^{s}(\omega, r)$};
    \draw [name path = ld] (0.5,4.5) coordinate (c) -- (4.5,0.5) node (d) [right] {$l^{d}(\omega)$};
    \path [name intersections={of=ls and ld, by=i}];
    \draw [dashed] (ejey.east |- i) node [left] {$\omega_{0}^{*}$} -| (i |- ejex) node [below] {$l_{0}^{*}$};
\end{tikzpicture}

\end{document}
share|improve this answer
add comment
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{intersections,calc}

\begin{document}

\begin{tikzpicture}
    \draw [<->] (0,5) coordinate (ejey) |- (5.5,0) coordinate (ejex);
    \node [left] at (ejey) {$\omega$};
    \node [right] at (ejex)  {$l$};
    \draw [name path = ls] (0.5,0.5) coordinate (a) -- (4.5,4.5) node    (b) [right] {$l^{s}(\omega, r)$};
    \draw [name path = ld] (0.5,4.5) coordinate (c) -- (4.5,0.5) node    (d) [right] {$l^{d}(\omega)$};
    \path [name intersections={of=ls and ld, by=i}];
    \draw [dashed] (ejey |- i) node [left] {$\omega_{0}^{*}$} -| (i |- ejex)    node [below] {$l_{0}^{*}$};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.