Feature Request: Adding Diagrams
Closed this issue · 2 comments
It should be possible to add diagrams.
I added diagrams in my thesis, the following way:
config: Add packages
\usepackage{pgfplotstable}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
tex:
\begin{figure}[ht!]
\caption{Anzahl relevanter Artikel im Zeitraum 1999/01/01 - 1999/03/31}
\label{dia:SPZ-90D}
\begin{tikzpicture}
\begin{axis}[
ybar, width = \linewidth,
% set column separator
table/col sep=tab,
xtick=data,
xticklabels from table={Datapoints/90D.tsv}{Lambda},
ylabel={Anzahl relevanter Artikel},
xlabel={Lambda-Wert},
ymax=30
]
\addplot table [
x expr=\coordindex,
y=SBERT,
] {Datapoints/90D.tsv};
\addlegendentry{NS-SBERT}
\addplot table [
x expr=\coordindex,
y=TF-IDF,
] {Datapoints/90D.tsv};
\addlegendentry{NS-TF-IDF}
\addplot table [
x expr=\coordindex,
y=SUMMARY,
] {Datapoints/90D.tsv};
\addlegendentry{NS-Summary}
\addplot table [
x expr=\coordindex,
y=WSBERT,
] {Datapoints/90D.tsv};
\addlegendentry{WIKI-SBERT}
\addplot table [
x expr=\coordindex,
y=WTF-IDF,
] {Datapoints/90D.tsv};
\addlegendentry{Wikipedia-TF-IDF}
\addplot table [
x expr=\coordindex,
y=WSUMMARY,
] {Datapoints/90D.tsv};
\addlegendentry{Wikipedia-Summary}
\end{axis}
\end{tikzpicture}
\end{figure}
I also enabled a time based y axis. For this some small configurations needs to be added:
\def\removeleadingzeros#1{\if0#1 \expandafter\else#1\fi} % needed because, if number is e.g 08 you get an base-8 error
\def\transformtime#1:#2:#3!{
% \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
\pgfmathparse{\removeleadingzeros#1*3600-\pgfkeysvalueof{/pgfplots/timeplot zero}3600+\removeleadingzeros#260+\removeleadingzeros#3}
% \pgfkeys{/pgf/fpu=false}
}
\pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
y coord trafo/.code={\expandafter\transformtime##1!},
y coord inv trafo/.code={%
% \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed,}
\pgfmathsetmacro\hours{floor(##1/3600)+\pgfkeysvalueof{/pgfplots/timeplot zero}}
\pgfmathsetmacro\minutes{floor((##1-(\hours - \pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
\pgfmathsetmacro\seconds{##1-floor((##1)/60)*60}
\def\pgfmathresult{%
\pgfmathparse{ifthenelse( \hours<10,0,)}\pgfmathresult\pgfmathprintnumber{\hours}:%
\pgfmathparse{ifthenelse(\minutes<10,0,)}\pgfmathresult\pgfmathprintnumber{\minutes}:%
\pgfmathparse{ifthenelse(\seconds<10,0,)}\pgfmathresult\pgfmathprintnumber[fixed,fixed]{\seconds}%
}
% \pgfkeys{/pgf/fpu=false}
},
scaled y ticks=false,
yticklabel=\tick
}
}
Tex
\begin{figure}[ht!]
\caption{Selektionszeiten}
\label{dia:SEL-TIME}
\begin{tikzpicture}
\begin{axis}[
ybar, width = \linewidth,
nodes near coords align=below,
enlarge y limits={value=0.2,upper},
timeplot, timeplot zero=0, grid=major, grid style=dashed, % timeplot uses our configuration
table/col sep=tab,
xtick=data,
xticklabels from table={Datapoints/Validation_Master - Sel_Time.tsv}{Daterange},
x tick label style={align=left, rotate=45, font=\scriptsize, anchor=north east},
%title={Selektionszeiten},
ylabel={Selektionszeit},
ylabel style={at=(current axis.above origin), rotate=-90, anchor=south},
xlabel={Zeiträume},
xlabel style={at=(current axis.right of origin), anchor=west}
]
\addplot table [
x expr=\coordindex,
y={SBERT}
]{Datapoints/Validation_Master - Sel_Time.tsv};
\addlegendentry{SBERT}
\addplot table [
x expr=\coordindex,
y={TF-IDF}
]{Datapoints/Validation_Master - Sel_Time.tsv};
\addlegendentry{TF-IDF}
\addplot table [
x expr=\coordindex,
y={SUMMARY}
]{Datapoints/Validation_Master - Sel_Time.tsv};
\addlegendentry{SUMMARY}
\end{axis}
\end{tikzpicture}
\end{figure}
If you need the tsv files.
contact me under: m-moser1@gmx.de
Wurde als "Best Practice" ins Wiki aufgenommen: https://github.com/systemtechniklabor/htwsaar-i-mst-vorlage/wiki/diagrammepgfplots
.tsv Dateien für das Beispiel.
tsv-files.zip