I would like to draw a scatterplot like create scatter plot from dat file of a table containing data (actually in an external file) structured label, x=x, and y=y, but keep getting errors with the label names. LaTex reads Direct Care
as two separate columns, how would I correct this? Can be using Tikz, pgfplot or other at your discretion. No need for data labels however.
\documentclass{article}
\usepackage{pgfplots,filecontents}
\pgfplotsset{compat=1.7}
\begin{filecontents*}{mydata.dat}
label x y
Direct Care 3 1
Housekeeping 2.366666667 5
Mealtimes 1 1
Medication Round 2.7 7
Miscellaneous 0.883333333 1
Personal Care 8 5
\end{filecontents*}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[xlabel=Time(mins),ylabel=Surface contacts]
\addplot[
visualization depends on={\thisrow{nodes}\as\myvalue},
scatter/classes={
Direct Care={mark=*,blue},
Housekeeping={mark=*,red},
Mealtimes={mark=*,blue},
Medication Round={mark=*,red},
Miscellaneous={mark=*,blue},
Personal Care={mark=*,red},
},
scatter, only marks,
scatter src=explicit symbolic,
]
table[meta=label,x=x,y=y]
{mydata.dat};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
