# pgfplots - how to draw seconds from csv in hours:minute format?

I have data in a .csv file with seconds as x values. I'd like to tick the x axis in hours:minute formate e.g.: 0:00 , 0:30 , 1:00 , 1:30 ...

How do I have to redefine the interpretation of values to fit into that different presentation style?

data sample

    seconds values
30       3.98
60       3.97
90       3.96
120      3.96
150      3.95
...      ...
3210      3.45

• Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Especially some example data would be helpful. Oct 25 '13 at 10:50
• So your x coordinates are simply seconds, not minutes:seconds, right?
– Jake
Oct 25 '13 at 11:02
• jepp, just seconds like x column: 560 y column: 3.98 Oct 25 '13 at 11:07
• Oct 25 '13 at 11:08
• @Alenanno: All those examples address a different problem, where the time is formatted using minutes:seconds.
– Jake
Oct 25 '13 at 11:19

You can convert the seconds to hours by using an x filter, and then split the hours and minuts for the labels within the xticklabel expression:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% Convert seconds to hours
x filter/.code={\pgfmathparse{#1/3600}},
xticklabel={ % Split into hours and minutes
\pgfmathsetmacro\hours{floor(\tick)}%
\pgfmathsetmacro\minutes{(\tick-\hours)*0.6}%
% Use some trickery to get leading zeros
\pgfmathprintnumber{\hours}:\pgfmathprintnumber[fixed, fixed zerofill, skip 0.=true, dec sep={}]{\minutes}%
},
xtick={0,0.25,...,1}
]