3

I am new to pgfplots and have a problem with the following example:

\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}

Looks ok, except that there are duplicate labels on the y axis. result of the tikz code with marked problems

How can I remove the labels I marked with red?

  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE). – Bobyandbob Aug 14 '17 at 9:48
  • 2
    You could remove the double entries e.g. by adding ytick distance=1 to the axis environment options. – Stefan Pinnow Aug 14 '17 at 11:20
  • Great to here. Shall I write an answer or shall we close this question as "solved in the comments"? – Stefan Pinnow Aug 14 '17 at 11:49
  • If you write a answer with the solution I'll accept it, thanks. – Josef Aug 14 '17 at 12:00
  • 1
    @TorbjørnT., you are right, that works in this case, because in the first \addplot command all symbolic coords are given. But this is not a general solution ... – Stefan Pinnow Aug 15 '17 at 6:45
3

As I already stated in the comment below the question you can e.g. remove the double yticks and the corresponding labels by adding ytick distance=1 to the axis environment options.

% 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}

image showing the result of above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.