1

I'd like to disable the top border of the plot. To do so, I used axis x line = bottom. However, this changed the plots content (the left most and right most bar are now hidden). How can I achieve this without changing the plot content?

Here is a minimal example:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{xcolor}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\usepackage{filecontents}
\pgfplotsset{
axis x line = bottom,
every x tick label/.append style={rotate=45,anchor=east,yshift=-0.3cm},
}

\begin{filecontents}{minimal.csv}
Datum;A;B;X;Y
2017-05-01;2.92;4.08;135861;14767
2017-06-01;2.92;4.08;135861;14767
2017-07-01;2.85;4.85;137600;96389
2017-08-01;2.78;5.42;137032;16351
2017-09-01;2.75;5.40;108018;56753
2017-10-01;2.66;4.97;156561;40026
\end{filecontents}

\begin{document}


\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
  date coordinates in=x,
  ybar,
  xtick=data,
]
\addplot table [x = Datum, y = X, col sep=semicolon] {minimal.csv}; 
\addplot table [x = Datum, y = Y, col sep=semicolon] {minimal.csv}; 
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}
  • 3
    Try the starred version: axis x line* = bottom – esdd Nov 23 '17 at 13:35
  • Thanks, this works, if you add an answer I'll mark it as correct – Klaus Stadler Nov 23 '17 at 14:36
1

You could use the starred version: axis x line*=bottom. From pgfplots manual:

The starred versions . . . line* only affect the axis lines, without correcting the positions of axis labels, tick lines or other keys which are (possibly) affected by a changed axis line.

enter image description here

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}% loads tikz, xcolor, graphicx
\pgfplotsset{compat=1.15}% <- added, current version is 1.15
\usepgfplotslibrary{dateplot}
\usepackage{filecontents}
\pgfplotsset{
axis x line* = bottom,% <- changed
every x tick label/.append style={rotate=45,anchor=east,yshift=-0.3cm},
}

\begin{filecontents}{minimal.csv}
Datum;A;B;X;Y
2017-05-01;2.92;4.08;135861;14767
2017-06-01;2.92;4.08;135861;14767
2017-07-01;2.85;4.85;137600;96389
2017-08-01;2.78;5.42;137032;16351
2017-09-01;2.75;5.40;108018;56753
2017-10-01;2.66;4.97;156561;40026
\end{filecontents}

\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}[
  date coordinates in=x,
  ybar,
  xtick=data,
]
\addplot table [x = Datum, y = X, col sep=semicolon] {minimal.csv}; 
\addplot table [x = Datum, y = Y, col sep=semicolon] {minimal.csv}; 
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

Note that it is recommended to add a compat after loading pgfplots. Current version is 1.15.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.