3
\documentclass{scrartcl}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
  \begin{tikzpicture}
  \begin{axis}[
        symbolic y coords={A},
        ytick={A}, % I want to have B here
    ]
    \addplot+[only marks] coordinates {
    (1,{A})
    };
  \end{axis}
  \end{tikzpicture}
\end{document}

I want to have the tick label say B as a first step. Entering B in the indicated spot throws:

Package pgfplots Error: Sorry, the input coordinate `B' has not been defined mething like [normalized]B?. ]

If this is possible I want (as the second step) that the label says B with a nice circle around it which I draw elsewhere in my document with the macro:

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
        \node[shape=circle,draw,inner sep=1pt,font=\footnotesize] (char) {#1};}}

Typing ytick={\circled{B}} causes pdfLaTeX to hang.

  • yticklabel and ytick are different things – percusse Mar 26 '16 at 19:02
2

Answering my own question here thanks to the hint given by @percusse. One needs to specify symbolic y coords, ytick and yticklabels. Not sure why though.

\documentclass{scrartcl}

\usepackage{tikz}
\usepackage{pgfplots}

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
        \node[shape=circle,draw,inner sep=1pt,font=\footnotesize] (char) {#1};}}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    symbolic y coords={{A},{C}},
    ytick={A,C},
    yticklabels={\circled{B1},\circled{B2}},
    ]
    \addplot+[only marks] coordinates {
        (1,{A})
    };
    \addplot+[only marks] coordinates {
        (2,{C})
    };
    \end{axis}
    \end{tikzpicture}
\end{document}

Output

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.