仅改变 y 轴上的箭头方向

仅改变 y 轴上的箭头方向

我想改变 y 轴上箭头的方向,以便 0 仍然从顶部开始并且负数沿箭头方向增加。这是代码(我有更多的图表,这就是我添加的原因groupplot,但为了方便您,我删除了它们):

  \usetikzlibrary{pgfplots.groupplots}
  \usetikzlibrary{patterns}

\begin{tikzpicture}
      \pgfplotsset{%
%  width=4cm,
%  height=2cm,
%  scale only axis,
  ymajorgrids,
  yminorgrids,
  y axis line style = ultra thick,
  nodes near coords,
    nodes near coords align={vertical},
    every node near coord/.append style={font=\tiny,black},
    axis y line  = left,    
    y axis line style = ultra thick,
    ybar legend,
    axis on top=false,
    %y dir=reverse,
    %allow reversal of rel axis cs=false,
}  

\begin{groupplot}[
    group style={
        group name=my plots,
        group size=1 by 11,
        xlabels at=edge bottom,
        xticklabels at=edge bottom,
        vertical sep=12pt,                
    },
    ybar,
    footnotesize,
    width=8cm,
    height=3cm,
    xlabel=Site,
    xmin=0, xmax=6,
    xtick=data,
    xticklabels={Variante1,Variante2,Variante3,Variante4,Variante5},
    x tick label style={rotate=-90,anchor=west},
    ylabel style={rotate=-90},
    tickpos=left,
    ytick align=outside,
    xtick align=outside,   
    axis on top=false,     
]      

      \nextgroupplot[ymax=0.0,ymin=-2500]
      \addplot[black, pattern color=black,
        %bar shift=2.5mm,
        fill=blue,
        postaction={
        pattern=north east lines
        },
        draw,
      ] coordinates { (1, -773.8) (2, -1875.6) (3,-1879.76) (4,-1271.16)(5,-1274.92) };

      \end{groupplot}
\end{tikzpicture}

这是输出:

在此处输入图片描述

但它应该看起来像这样:

在此处输入图片描述

有人能帮助我吗?

答案1

在此处输入图片描述

您可以使用

    y axis line style = {ultra thick,stealth-},

(默认样式使用-stealth)。

代码:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
      \pgfplotsset{%
%  width=4cm,
%  height=2cm,
%  scale only axis,
  ymajorgrids,
  yminorgrids,
  y axis line style = ultra thick,
  nodes near coords,
    nodes near coords align={vertical},
    every node near coord/.append style={font=\tiny,black},
    axis y line  = left,    
    y axis line style = {ultra thick,stealth-},
    ybar legend,
    axis on top=false,
    %y dir=reverse,
    %allow reversal of rel axis cs=false,
}  

\begin{groupplot}[
    group style={
        group name=my plots,
        group size=1 by 11,
        xlabels at=edge bottom,
        xticklabels at=edge bottom,
        vertical sep=12pt,                
    },
    ybar,
    footnotesize,
    width=8cm,
    height=3cm,
    xlabel=Site,
    xmin=0, xmax=6,
    xtick=data,
    xticklabels={Variante1,Variante2,Variante3,Variante4,Variante5},
    x tick label style={rotate=-90,anchor=west},
    ylabel style={rotate=-90},
    tickpos=left,
    ytick align=outside,
    xtick align=outside,   
    axis on top=false,     
]      

      \nextgroupplot[ymax=0.0,ymin=-2500]
      \addplot[black, pattern color=black,
        %bar shift=2.5mm,
        fill=blue,
        postaction={
        pattern=north east lines
        },
        draw,
      ] coordinates { (1, -773.8) (2, -1875.6) (3,-1879.76) (4,-1271.16)(5,-1274.92) };

      \end{groupplot}
\end{tikzpicture}

\end{document}

相关内容