Fix dates on x axis

This commit is contained in:
2023-12-31 21:39:53 +01:00
parent 1dab0d748f
commit dd9e44eace
2 changed files with 56 additions and 16 deletions

View File

@@ -4,6 +4,7 @@
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{pgfplots.dateplot}
% Other packages
\usepackage[a4paper, total={12cm, 25cm}]{geometry}
@@ -30,6 +31,10 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcommand*\shortyear[1]{\expandafter\@gobbletwo\number\numexpr#1\relax}
\makeatother
\newcommand{\slice}[6]{
\pgfmathparse{0.5*#1+0.5*#2}
\let\midangle\pgfmathresult
@@ -136,15 +141,28 @@
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
width=\textwidth,
height=0.375\textwidth,
ylabel={Net income in €},
y label style={at={(-0.1,0.5)},anchor=south},
xticklabel=\month.\shortyear{\year},
xtick=data,
xticklabel style={
rotate=60,
anchor=near xticklabel,
},
grid,
]
\addplot+[ybar, color=scol2, fill=scol2, line width=1pt]
% Dummy plot to set x axis labels
\addplot[draw=none]
table[col sep=comma, x=t, y=value]
{net_income.csv};
\addplot[ybar, color=scol2, fill=scol2, line width=1pt]
table[col sep=comma, x=t, y=value, discard if lt={value}{0}]
{net_income.csv};
\addplot+[ybar, color=scol0, fill=scol0, line width=1pt]
\addplot[ybar, color=scol0, fill=scol0, line width=1pt]
table[col sep=comma, x=t, y=value, discard if gt={value}{0}]
{net_income.csv};
\end{axis}
@@ -155,11 +173,19 @@
\begin{tikzpicture}
\begin{axis}[
date coordinates in=x,
width=\textwidth,
height=0.375\textwidth,
area style,
ylabel={Total balance in €},
y label style={at={(-0.1,0.5)},anchor=south},
xticklabel=\month.\shortyear{\year},
xtick=data,
xticklabel style={
rotate=60,
anchor=near xticklabel,
},
grid,
]
\addplot+[mark=none, color=scol1, line width=1pt]
table[col sep=comma, x=t, y=value]