4

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

2 Answers 2

5

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.