xtick latex hour option

I have many graph using date as x axis, and I wonder if there is an option of xtick to put a tick every hour automatically and not writting every tick like that :

xtick = {
{2018-04-27 05:00},
{2018-04-27 06:00},
{2018-04-27 07:00},
{2018-04-27 08:00},
{2018-04-27 09:00},
{2018-04-27 10:00},
{2018-04-27 11:00},
{2018-04-27 12:00},
{2018-04-27 13:00},
{2018-04-27 14:00},
{2018-04-27 15:00},
{2018-04-27 16:00},
{2018-04-27 17:00},
{2018-04-27 18:00},
{2018-04-27 19:00},
{2018-04-27 20:00}
}


Cause I've tried this, that didn't worked and that I know works for years alone :

xtick = {
{2018-04-27 05:00},
{2018-04-27 06:00},
...,
{2018-04-27 20:00}
}


Here is an exemple of what I would like to get in the end :

Thank you !

• Where do the X and Y values come from? If it is from a file, then tex.stackexchange.com/questions/267452/… might be interesting, otherwise maybe tex.stackexchange.com/questions/133857/…. Can you make a complete MWE that shows a plot with the manual list of xticks? That will help in understanding the problem and finding a solution. – Marijn Jul 27 '18 at 11:30
• If you need to cover more than one day, you might use the Unix time which is just a number of seconds since specified time therefore easy to increment. Then you can convert it to more readable format using methods from this queation: tex.stackexchange.com/a/147707/131547 – SPQR211 Jul 27 '18 at 11:36
• @Marijn Well I added a picture, but the link didn't showed it :( – Hugo Vernier-Lambert Jul 27 '18 at 12:09
• @SPQR211 I'm gonna look at this and come back if needed – Hugo Vernier-Lambert Jul 27 '18 at 12:11

If only the hour changes, you might want to consider using only the hour as a ticklabel.

If you definitely want the entire time/date, you can use the xticklabel option as follows:

\documentclass[tikz,margin=2mm]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xticklabel = {%
\pgfmathparse{int(\tick)<10?"0":{},int(\tick)}%
2018-04-27 \pgfmathresult:00%
},
xticklabel style={rotate=90,anchor=east},
xtick distance=1,
xmin = 5,
xmax = 20,
]