Tikz 每个 y 值具有多个坐标的条形图

Tikz 每个 y 值具有多个坐标的条形图

我对以下代码有一些问题:

\begin{figure}
\caption{test}\label{fig:sourceType}
\begin{center}
\begin{tikzpicture}
    \begin{axis}[
            xbar,
            reverse legend,
            width = \textwidth,
            height = \textheight,
            symbolic y coords={motorway,primary,secondary,tertiary,unclassified/unknown,service},
            xticklabel={\pgfmathparse{\tick*100}\pgfmathprintnumber{\pgfmathresult}\%},
            xlabel = Relative frequency
        ]

        \addplot[blue!20!black,fill=blue!10!white] coordinates {
        (0.0135,motorway)
        (0.02,primary)
        (0.0797,secondary)
        (0.1027,tertiary)
        (0.1453,unclassified/unknown)
        (0.1904,service)
        };

        \addplot[blue!20!black,fill=blue!40!white] coordinates {
        (0.0129,motorway)
        (0.0192,primary)
        (0.0821,secondary)
        (0.1121,tertiary)
        (0.1656,unclassified/unknown)
        (0.1762,service)
        };

        \addplot[blue!20!black,fill=blue!70!white] coordinates {
        (0.0119,motorway)
        (0.0199,primary)
        (0.0767,secondary)
        (0.1117,tertiary)
        (0.1751,unclassified/unknown)
        (0.1813,service)
        };

        \addplot[blue!20!black,fill=blue!100!white] coordinates {
        (0.0154,motorway)
        (0.0231,primary)
        (0.0805,secondary)
        (0.1052,tertiary)
        (0.1444,unclassified/unknown)
        (0.1871,service)
        };

        \addplot[red!20!black,fill=red!80!white] coordinates {
        (0.0159,motorway)
        (0.0158,primary)
        (0.072,secondary)
        (0.0895,tertiary)
        (0.1189,unclassified/unknown)
        (0.2129,service)
        };
\legend {Stgt};
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}

结果如下: 图像

我如何去掉重复的 y 标签,只保留中间的标签(需要明确哪 5 个条属于哪个标签)?高度仅选择为最大值以使条不重叠,并且可以随时更改。提前致谢 :D

相关内容