0

enter image description here

I have a plot where I have 2 arrows with nodes. For the red one I used \draw [<-,red,line width=0.6pt] (6,8) -- (30,8) node [right,black,draw=red,fill=white] {$\dfrac{a}{b}=\dfrac{3}{2}$}; command, which produced a left pointing arrow with the node on its right end. I used the command \draw [->,blue,line width=0.6pt] (0.6,8) -- (3,8) node [left,black,draw=blue,fill=white] {$\dfrac{a}{b}=\dfrac{5}{2}$}; for the blue one, but it didn't result in a right pointing arrow with the node on its left end. Can someone, please, explain it to me why it didn't work and how can I fix it? Below is the full code.

\documentclass{standalone}

\usepackage{amsmath,amssymb}
\usepackage{graphicx}% Include figure files
\usepackage{bm}
\usepackage[numbers,super,comma,sort&compress]{natbib}
\usepackage{tikz}
\usetikzlibrary{tikzmark,patterns}
\usetikzlibrary{arrows,arrows.meta,shapes.arrows}
\tikzset{>=latex}
\usepackage{pgfplots}
\usepackage{pgfplotstable}%fitting functions

\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    xmode=log,
    width=8cm,
    height=6cm,
    axis line style={line width=0.6pt},
    x label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    xlabel={$x$},
    xmin=0.1,xmax=1000,
    xtick={0.1,1,10,100,1000},
    xtick align=inside,
    y label style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel={$y$},
    ymin=0,ymax=10,
    ytick={0,2,...,10},
    ytick align=inside,
]

\addplot [red,line width=0.6pt,domain=0.1:10,samples=200] {3*x/2};
\addplot [blue,line width=0.6pt,domain=0.1:10,samples=200] {5*x/2};

\draw [<-,red,line width=0.6pt] (6,8) -- (30,8) node [right,black,draw=red,fill=white] {$\dfrac{a}{b}=\dfrac{3}{2}$};
\draw [->,blue,line width=0.6pt] (0.6,8) -- (3,8) node [left,black,draw=blue,fill=white] {$\dfrac{a}{b}=\dfrac{5}{2}$};

\end{axis}
\end{tikzpicture}

\end{document}
5
  • For some reason the image isn't displayed. Sorry about that. It never happened before and I cannot fix it.
    – Gagik
    Commented Oct 6, 2023 at 13:34
  • 2
    with `\draw [->,blue,line width=0.6pt] (0.6,8) node [left,black,draw=blue,fill=white] {$\dfrac{a}{b}=\dfrac{5}{2}$}-- (3,8) ;``
    – pascal974
    Commented Oct 6, 2023 at 13:43
  • 1
    @pascal974 Your comment is a good answer! Post is as an answer. Commented Oct 6, 2023 at 14:26
  • @pascal974 thanks a lot!
    – Gagik
    Commented Oct 6, 2023 at 15:23
  • You put the node on the right end of the line that points to the right. The node is covering the line. Out the node behind the start coordinate or reverse the coordinates (and the tip specification). Though, I'd use the canvas coordinate system for the length of the arrow or even a pin since you want the lines to have the same length. No need to mess around with the logarithmic axis cs. Commented Oct 6, 2023 at 22:40

0

You must log in to answer this question.

Browse other questions tagged .