2

In the following histogram from my.dat I would like that nodes near coords take the value of the number followed by a text. For example:

nodes near coords = {<Label> from \cite{<Cite>}}

The code I used is:

\begin{filecontents}{my.dat}
y   x   Label   Cite
1   0.9 AK  Hong
2   1.4 RE  Teng
3   2.1 QP  Smith
4   0.7 LR  Croqa
\end{filecontents}

\begin{tikzpicture}
\begin{axis}[
    xbar,
    width=8cm, height=5cm,
    axis lines*=left,
    xlabel={},
    yticklabels from table={my.dat}{Label},
    ytick=data,
    xticklabel={},
    nodes near coords={'Own Label' from \cite{'Own Cite'}},
    nodes near coords align={horizontal},
    ]
    \addplot table [x=x, y=y] {my.dat};
\end{axis}
\end{tikzpicture}

With this result:

enter image description here

Stefano
  • 1,038

1 Answers1

6

Is this what you're after? I used some random entries from biblatex-examples.bib in the code below.

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{textcomp}
\usepackage{siunitx}
\usepackage{pgfplotstable,filecontents}
\pgfplotsset{compat=1.12}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
\begin{filecontents*}{my.dat}
y   x   Label   Cite
1   0.9 AK      aksin
2   1.4 RE      angenendt
3   2.1 QP      bertram
4   0.7 LR      doody
\end{filecontents*}

\noindent\begin{tikzpicture}
\begin{axis}[
    xbar,
    width=8cm, height=5cm,
    axis lines*=left,
    xlabel={},
    yticklabels from table={my.dat}{Label},
    ytick=data,
    xticklabel={},
    nodes near coords={\thenumber{} from \cite{\thecitation}},
    nodes near coords align={horizontal},
    visualization depends on={value \thisrow{Cite} \as \thecitation},
    visualization depends on={value \thisrow{x} \as \thenumber},
    ]
    \addplot table [x=x, y=y] {my.dat};
\end{axis}
\end{tikzpicture}

\printbibliography
\end{document}
Torbjørn T.
  • 206,688