Tikz 条形图问题:直方图缩放不正确

Tikz 条形图问题:直方图缩放不正确

我的 tikz 绘图有问题在此处输入图片描述,即使驱动器对应的值为 21508,从图中可以看出直方图的缩放比例不正确。我不知道为什么会这样。

我的代码如下:

         \documentclass{article}
         \usepackage[margin=0.5in]{geometry}
         \usepackage[utf8]{inputenc}
         \usepackage{textcomp}
        \usepackage{pgfplots}
        \pgfplotsset{compat=1.11}
        \usetikzlibrary{decorations.pathmorphing,patterns}

        \begin{document}
         \begin{tikzpicture} 

         \begin{axis}[title= \textbf{Before Simplification},
                scaled ticks=false, 
                tick label style={/pgf/number format/fixed},
                xbar ,
                width=0.99\textwidth,
                height=0.99\textwidth,
                enlarge y limits=0.15,
                enlarge x limits={upper, value=0.15},
                y axis line style = { opacity = 0 },
               axis x line       = none,
               tickwidth         = 0pt,
               xtick=\empty,
               ytick=data,
               y=-1cm,
               bar width=0.3cm,
               nodes near coords={
                            \pgfkeys{/pgf/fpu=true}
                            \pgfmathparse{abs(\pgfplotspointmeta)}
                            \pgfmathprintnumber{\pgfmathresult}
                         },
        nodes near coords align={horizontal},
        symbolic y coords = {drive,drive-service,walk,bike,all,all-private},
        legend pos = outer north east,] 
        \addplot [draw=blue,pattern=horizontal lines light blue] 
         coordinates {(21508,drive) (31963,drive-service) (47924,walk) (43923,bike) (53370,all) (56120,all-private)};
      \end{axis}
      \end{tikzpicture}
      \end{document}

我究竟做错了什么?

答案1

编辑:正如@moewe 所观察到的,插入xmin=0使所有条形图成比例。

在此处输入图片描述

相关内容