I am making an xbar plot with pgfplots. I want this plot to show the results from a test, where people in different age classes are given scores. For each of these age classes a single person is the winner. See the attached latex file containing the dataset "data.dat", with four columns: Age-interval, Y-position, Score, and Name.
I want my xbar plot to have different y tick labels on, respectively, the left and the right side y axes. The left side y tick labels denotes the age intervals of the persons tested (20-30, 30-40,...), while the right side y tick labels should denote the winner in each of the age intervals (Peter, Jeff, ...).
Two questions:
(1) I am not able to make a left side and a right side set of y tick labels simultaneously. How can I do that?
Adding two extra lines of code, for showing right side y tick labels (code block starting with "% (2) "), does not solve my problem, only shifting it from showing only the left side y tick labels to showing only the right side y tick labels
(2) How do I prevent the plot title to overlap with the x tick labels?
here is my code:
{\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=1.3}
% test scores and person names
\begin{filecontents}{data.dat}
Age-interval Y-Position Score Name
20-30 1 15 Peter
30-40 2 20 Jeff
40-50 3 12 Steve
50-60 4 24 John
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title = {Test score},
xbar,
bar width=2pt,
ytick=data,
width=8 cm,
height=5 cm,
xmin=-1,
xmax = 100,
xticklabel pos = upper,
tick align = outside,
%
% (1) add left side y tick labels
yticklabel pos=left,
yticklabels from table={data.dat}{Age-interval},
%
% (2) add righ side y tick labels
% yticklabel pos=right,
% yticklabels from table={data.dat}{Name},
%
ylabel={Age intervals (yr)},
]
\addplot table [
y=Y-Position,
x=Score,
] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}

