Tikz:堆积条形图的宽度和编号

Tikz:堆积条形图的宽度和编号

下面是一个条形图。但是,它有几个问题。首先,我想增加它的宽度,以便所有条形图分开并正确显示。其次,我想隐藏所有条形图的数字。第三,对于“%%%First data”(在代码中标识),我想完全隐藏图表中某些列的表示(例如,对于 (62,0)(63,0)(64,0)(65,0)(66,0))。最后,我只想显示x 标签对于几列(例如,1、5、10、...)。

在此处输入图片描述

\documentclass{article}

\usepackage{pgfplots}

\begin{document}


\begin{tikzpicture}
\begin{axis}[
    ybar stacked,
    bar width=5pt,
    nodes near coords,
    legend style={at={(0.5,-0.15)},
      anchor=north,legend columns=-1},
    symbolic x coords={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66},
    xtick=data,
    x tick label style={anchor=north},
    ]
    \addplot+[ybar, red!20!black,fill=red!80!white] plot coordinates %%%First data
    {(1,21)(2,38)(3,81)(4,63)(5,63)(6,34)(7,62)(8,40)(9,53)(10,54)(11,61)(12,15)(13,83)(14,41)(15,77)(16,100)(17,72)(18,66)(19,86)(20,81)(21,32)(22,49)(23,25)(24,88)(25,48)(26,87)(27,48)(28,92)(29,43)(30,60)(31,60)(32,33)(33,26)(34,70)(35,95)(36,0)(37,43)(38,27)(39,67)(40,26)(41,20)(42,21)(43,22)(44,16)(45,99)(46,55)(47,25)(48,28)(49,13)(50,23)(51,9)(52,7)(53,5)(54,0)(55,0)(56,90)(57,32)(58,16)(59,10)(60,7)(61,9)(62,0)(63,0)(64,0)(65,0)(66,0)
    };
    \addplot+[ybar] plot coordinates {(1,26)(2,10)(3,1)(4,0)(5,0)(6,0)(7,0)(8,0)(9,0)(10,0)(11,0)(12,3)(13,1)(14,2)(15,0)(16,0)(17,0)(18,0)(19,0)(20,0)(21,0)(22,0)(23,1)(24,0)(25,3)(26,0)(27,0)(28,0)(29,0)(30,0)(31,0)(32,0)(33,0)(34,0)(35,0)(36,0)(37,0)(38,0)(39,0)(40,0)(41,0)(42,0)(43,0)(44,0)(45,0)(46,0)(47,0)(48,0)(49,0)(50,0)(51,0)(52,0)(53,0)(54,0)(55,0)(56,0)(57,0)(58,0)(59,0)(60,0)(61,0)(62,0)(63,0)(64,0)(65,0)(66,0)};
    \addplot+[ybar] plot coordinates {(1,53)(2,52)(3,18)(4,37)(5,37)(6,66)(7,38)(8,60)(9,47)(10,46)(11,39)(12,82)(13,16)(14,57)(15,23)(16,0)(17,28)(18,34)(19,14)(20,19)(21,68)(22,51)(23,74)(24,12)(25,49)(26,13)(27,52)(28,8)(29,57)(30,40)(31,40)(32,67)(33,74)(34,30)(35,5)(36,100)(37,57)(38,73)(39,33)(40,74)(41,80)(42,79)(43,78)(44,84)(45,1)(46,45)(47,75)(48,72)(49,87)(50,77)(51,91)(52,93)(53,95)(54,100)(55,100)(56,10)(57,68)(58,84)(59,90)(60,93)(61,91)(62,100)(63,100)(64,100)(65,100)(66,100)};
  \legend{\strut MP,\strut  ACO, \Strut HT}
  \end{axis}
\end{tikzpicture}

\end{document}

相关内容