对于带有 pgfplots 的箱线图来说,尺寸太大

对于带有 pgfplots 的箱线图来说,尺寸太大

我无法显示 x 轴上的刻度标记。

       \starttikzpicture
       \startaxis[
        y=1.5cm,
        axis y line=none,
        axis x line=bottom,
        enlarge x limits,
        ultra thick,
        tickwidth=0.15cm,
        x tick label style={
           /pgf/number format/10000 sep={}
        },
        xtick={0,10000,...,80000},
        ymin=0,
        every tick/.style={
             black,
             thick,
        }, 
  ]

     \addplot+[
      darkred,line width=0.5mm,
      boxplot prepared={
      median=22400,
      upper quartile=34100,
      lower quartile=16300,
      upper whisker=78200,
      lower whisker=10400,
       },
      ] coordinates {};

    \stopaxis
    \stoptikzpicture

答案1

这是因为该xtick行。将其替换为xtick distance,它就可以正常工作。但是,如您所见,如果您不想要 x 轴值的“缩放”,则使用 10.000 作为值会导致标签重叠。

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{
        statistics,
    }
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        width=\axisdefaultwidth,
        height=4cm,
        axis y line=none,
        axis x line=bottom,
        enlarge x limits,
        ultra thick,
        tickwidth=0.15cm,
        x tick label style={
           /pgf/number format/1000 sep={},  % <-- (this was "10000")
        },
%        scaled ticks=false,                 % <-- (added, in case you don't want any scaling)
        xtick distance=10000,               % <-- replaced `xtick'
        ymin=0,
        every tick/.style={
             black,
             thick,
        },
    ]

        \addplot+[
            red,
            line width=0.5mm,
            boxplot prepared={
                median=22400,
                upper quartile=34100,
                lower quartile=16300,
                upper whisker=78200,
                lower whisker=10400,
            },
        ] coordinates {};
    \end{axis}
\end{tikzpicture}
\end{document}

该图显示了上述代码的结果

相关内容