For my current project, I need to display a series of percentage changes in a plot.
This is the code I have so far
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepgfplotslibrary{dateplot}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
date ZERO=2015-04-29 00:00,
%
xticklabel=\hour:\minute,
xticklabel style={rotate=45,anchor=north east},
xtick=data,
xlabel=Date,
%
ylabel=Percental change in stock price,
%
width=\textwidth
]
\addplot coordinates {
(2015-04-29 14:30, -0.08438)
(2015-04-29 15:00, 0.38414)
(2015-04-29 15:30, -0.59243)
(2015-04-29 16:00, -0.28056)
(2015-04-29 16:30, 0.20808)
(2015-04-29 17:00, -0.18451)
(2015-04-29 17:30, -0.83166)
(2015-04-29 18:00, 0.22455)
(2015-04-29 18:30, -0.06981)
(2015-04-29 19:00, 0.43784)
(2015-04-29 19:30, -0.12288)
(2015-04-29 20:00, -0.01929)
(2015-04-29 20:30, -0.38754)
(2015-04-29 21:00, 0.05445)
(2015-04-30 14:30, -0.80921)
(2015-04-30 15:00, -0.94902)
(2015-04-30 15:30, -0.72899)
(2015-04-30 16:00, 0.22255)
(2015-04-30 16:30, 0.21400)
(2015-04-30 17:00, -0.41150)
(2015-04-30 17:30, 0.00612)
(2015-04-30 18:00, -0.17905)
(2015-04-30 18:30, -0.02388)
(2015-04-30 19:00, 0.05997)
(2015-04-30 19:30, -0.29116)
(2015-04-30 20:00, -0.20734)
(2015-04-30 20:30, -0.02925)
(2015-04-30 21:00, 0.19214)
};
\end{axis}
\end{tikzpicture}
\end{document}
But this unfortunately this does not do exactly what I want.. This is the outcome:
Can someone explain how I can (preferably automatically) skip the hours for which no data is logged? Basically, this is what I want, but I cannot get it to work: Collapse range in x-axis with pgfplots? (break x-axis)
pgfplots
version 1.12. – percusse May 10 '15 at 6:22