删除带有符号 y 坐标的重复标签

删除带有符号 y 坐标的重复标签

我是 pgfplots 的新手,对以下示例有疑问:

\begin{tikzpicture}
  \begin{axis}[title  = Some fancy benchmark data,
    xbar,
    y axis line style = { opacity = 0 },
    axis x line       = none,
    tickwidth         = 0pt,
    enlarge y limits  = 0.2,
    enlarge x limits  = 0.02,
    symbolic y coords = {Intel Xeon E5630,AMD Turion II Neo N54L,Intel i7 3632QM},
    nodes near coords,
    nodes near coords style={/pgf/number format/.cd,precision=7}
  ]
  \addplot coordinates { (0.155,AMD Turion II Neo N54L)         (0.087,Intel i7 3632QM)
                         (0.134,Intel Xeon E5630)  };
  \addplot coordinates { (0.078,AMD Turion II Neo N54L)         (0.047,Intel i7 3632QM)
                         (0.069,Intel Xeon E5630)    };
  \legend{prod1, prod2}
  \end{axis}
\end{tikzpicture}

看起来不错,除了 y 轴上有重复的标签。 tikz 代码结果存在明显问题

我怎样才能删除我用红色标记的标签?

答案1

正如我在在问题下方评论ytick distance=1例如,您可以通过添加环境选项来删除双 yticks 和相应的标签axis

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        title=Some fancy benchmark data,
        xbar,
        y axis line style={
            draw=none,          % (<-- changed)
        },
        axis x line=none,
        tickwidth=0pt,
        enlarge y limits=0.2,
        enlarge x limits=0.02,
        symbolic y coords={
            Intel Xeon E5630,
            AMD Turion II Neo N54L,
            Intel i7 3632QM%
        },
        nodes near coords,
        nodes near coords style={
            /pgf/number format/precision=4,
        },
        ytick distance=1,       % <-- added
    ]
        \addplot coordinates {
            (0.155,AMD Turion II Neo N54L)
            (0.087,Intel i7 3632QM)
            (0.134,Intel Xeon E5630)
        };
        \addplot coordinates {
            (0.078,AMD Turion II Neo N54L)
            (0.047,Intel i7 3632QM)
            (0.069,Intel Xeon E5630)
        };
        \legend{
            prod1,
            prod2,
        }
    \end{axis}
\end{tikzpicture}
\end{document}

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

相关内容