von esdd » Mo 31. Jul 2017, 21:43
Sieht zwar für mich etwas seltsam aus, ist aber mit etwas Bastelei machbar:
\documentclass[border=1cm]{standalone}
\usepackage{pgfplotstable}% lädt auch pgfplots und tikz
\pgfplotsset{compat=newest}% immer compat setzen; aktuell ist derzeit Version 1.15
\usepackage{filecontents}
\begin{filecontents}{mytable.csv}
X,Y
Label1,4
Label2,3
\end{filecontents}
\pgfplotstableread[col sep=comma]{mytable.csv}\testtable
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=left,
axis line shift=10pt,
%enlarge x limits={abs=1cm},
xtick=data,
xticklabels from table={\testtable}{X},
xticklabel style={rotate=50,anchor=east},
%
minor xtick={-0.5,.5,1.5},
xmin=-.5, xmax=1.6,
tickwidth=0pt,
subtickwidth=5pt
]
\addplot [mark=diamond] table [x expr=\coordindex,y=Y] {\testtable};
\end{axis}
\end{tikzpicture}
\end{document}
Sieht zwar für mich etwas seltsam aus, ist aber mit etwas Bastelei machbar:
[code]\documentclass[border=1cm]{standalone}
\usepackage{pgfplotstable}% lädt auch pgfplots und tikz
\pgfplotsset{compat=newest}% immer compat setzen; aktuell ist derzeit Version 1.15
\usepackage{filecontents}
\begin{filecontents}{mytable.csv}
X,Y
Label1,4
Label2,3
\end{filecontents}
\pgfplotstableread[col sep=comma]{mytable.csv}\testtable
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=left,
axis line shift=10pt,
%enlarge x limits={abs=1cm},
xtick=data,
xticklabels from table={\testtable}{X},
xticklabel style={rotate=50,anchor=east},
%
minor xtick={-0.5,.5,1.5},
xmin=-.5, xmax=1.6,
tickwidth=0pt,
subtickwidth=5pt
]
\addplot [mark=diamond] table [x expr=\coordindex,y=Y] {\testtable};
\end{axis}
\end{tikzpicture}
\end{document}[/code]