1

There seems to be a conflict between y axis line style and y dir : in fact, although I have specified the y axis style, it still remain with the arrow pointing down

My MWE

\documentclass[12pt]{article}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\pgfplotsset{
  every mark/.append style={mark size=0.5pt},
  grid, grid style={dashed, draw=gray!10},
  legend image with text/.style={
        legend image code/.code={%
            \node[anchor=center] at (0.3cm,0cm) {#1};
        }
    },
}
\begin{document}
\begin{tikzpicture}
      \begin{axis}[
      legend pos=outer north east,
      legend cell align={left},
     grid, grid style=dashed,
      ymin=-100,ymax=0,
      xmax=1,xmin=0,
      y axis line style = {stealth-},
      y dir=reverse,
      extra x ticks={0},
      extra y ticks={0},
                width=10cm,
                height=10cm,
      axis lines = middle,
      set layers,
      x label style={at={(1,0)},right},
      y label style={at={(0,1)},above},
      xlabel={x},ylabel={y}, 
      style={thick}
                   ]              
            \addplot[only marks, mark=square*,magenta] coordinates {(0.041,-46.4)(0.519,-70.0)(0.748,-84.4)(0.898,-91.0)(1,-96.4)};
        \end{axis}
    \end{tikzpicture}
\end{document}
1

If you set axis lines=middle before the y axis line style then it also works. The starred variant is not needed.

\documentclass[12pt]{article}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\pgfplotsset{
  every mark/.append style={mark size=0.5pt},
  grid, grid style={dashed, draw=gray!10},
  legend image with text/.style={
        legend image code/.code={%
            \node[anchor=center] at (0.3cm,0cm) {#1};
        }
    },
}
\begin{document}
\begin{tikzpicture}
      \begin{axis}[
      legend pos=outer north east,
      legend cell align={left},
      grid, grid style=dashed,
      ymin=-100, ymax=0,
      xmax=1, xmin=0,
      % set this before the line style
      axis lines = middle,
      y axis line style = {stealth-},
      y dir=reverse,
      extra x ticks={0},
      extra y ticks={0},
      width=10cm,
      height=10cm,
      set layers,
      x label style={at={(1,0)},right},
      y label style={at={(0,1)},above},
      xlabel={x},ylabel={y}, 
      style={thick}
                   ]              
            \addplot[only marks, mark=square*,magenta] coordinates {(0.041,-46.4)(0.519,-70.0)(0.748,-84.4)(0.898,-91.0)(1,-96.4)};
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
  • Yes, that's exaclty what I need. Thank you! – user3204810 Aug 10 at 15:47
0

I'm not sure I understand the problem. Is this what you want?

enter image description here

\documentclass[12pt]{article}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\pgfplotsset{
  every mark/.append style={mark size=0.5pt},
  grid, grid style={dashed, draw=gray!10},
  legend image with text/.style={
        legend image code/.code={%
            \node[anchor=center] at (0.3cm,0cm) {#1};
        }
    },
}
\begin{document}
\begin{tikzpicture}
      \begin{axis}[
      legend pos=outer north east,
      legend cell align={left},
     grid, grid style=dashed,
      ymin=-100,ymax=5,
      xmax=1.2,xmin=0,
%      y axis line style = {stealth-},
      %y dir=reverse,
      %extra x ticks={0},
      %extra y ticks={0},
                width=10cm,
                height=10cm,
       axis x line = bottom,
       axis y line = left,
      set layers,
      x label style={at={(1,0)},right},
      y label style={at={(0,1)},above},
      xlabel={x},ylabel={y}, 
      style={thick}
                   ]              
            \addplot[only marks, mark=square*,magenta] coordinates {(0.041,-46.4)(0.519,-70.0)(0.748,-84.4)(0.898,-91.0)(1,-96.4)};
        \end{axis}
    \end{tikzpicture}
\end{document}
| improve this answer | |
0

Use the starred variant of axis line. Then it won't overwrite the axis style and you can define where the arrow is:

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{
  every mark/.append style={mark size=0.5pt},
  grid, grid style={dashed, draw=gray!10},
  legend image with text/.style={
        legend image code/.code={%
            \node[anchor=center] at (0.3cm,0cm) {#1};
        }
    },
}
\begin{document}
\begin{tikzpicture}
      \begin{axis}[
      legend pos=outer north east,
      legend cell align={left},
      grid, grid style=dashed,
      ymin=-100,ymax=0,
      xmax=1,xmin=0,
      y dir=reverse,
      y axis line style = {stealth-},
      extra x ticks={0},
      extra y ticks={0},
                width=10cm,
                height=10cm,
      axis lines* = middle,
      set layers,
      x label style={at={(1,0)},right},
      y label style={at={(0,1)},above},
      xlabel={x},ylabel={y},
      style={thick}
                   ]
            \addplot[only marks, mark=square*,magenta] coordinates {(0.041,-46.4)(0.519,-70.0)(0.748,-84.4)(0.898,-91.0)(1,-96.4)};
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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