Commit 789c412c authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Add an example of creating a graph using pgfplots.

parent bd46ef92
*.aux
*.log
*.out
*.pdf
export TEXINPUTS=.:..:
.PHONY: all clean
all:
pdflatex plot
clean:
@ rm -f `cat .gitignore`
@ rm -f *~
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[colorlinks=true,linkcolor=blue!80!black,pdfpagelabels=false]{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\input{setup.tex}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
% Figure width:
width=\textwidth,
% Horizontal axis settings:
xmode=log,
log basis x=10,
xlabel={Size of LR(1) automaton (\#states)},
scaled x ticks=false,
x tick label style={/pgf/number format/fixed},
% Vertical axis settings:
ymode=log,
log basis y=10,
ylabel={Construction time (seconds)},
]
\addplot[
% Appearance:
black,only marks,mark=o,
% Data filtering:
discard if not symbolic={mode}{pager}
]
table[col sep=comma,
% Horizontal axis data:
x=lr1states,
% Vertical axis data:
y=lr1time,
% Data filtering:
restrict expr to domain={rawy}{0.05:60},
]
{data.csv}
;
\end{axis}
\end{tikzpicture}
\caption{Efficiency of Pager's algorithm}
\end{figure}
\end{document}
% Possible values of the mark field:
% + (cross)
% o (white bullet)
% * (black bullet)
% triangle (white triangle)
% triangle* (black triangle)
% square* (black square)
% Possible values of the xmode and ymode fields:
% normal (linear)
% log (logarithmic)
% Instead of y=lr1time,
% one can also say
% y expr={\thisrow{lr1time}}
% Instead of restrict y to domain={0.05}{60},
% one can also say
% restrict expr to domain={\thisrow{lr1time}}{0.05:60}
\pgfplotsset{
% For numeric comparisons:
% https://tex.stackexchange.com/questions/178629/how-to-read-a-specific-portion-of-a-data-file-in-pgfplots
discard if not/.style 2 args={
x filter/.code={
\let\tempa=\pgfmathresult
\pgfmathparse{\thisrow{#1}==#2?\tempa:"inf"}
}
},
% For symbolic comparisons:
% https://tex.stackexchange.com/questions/58548/is-it-possible-to-change-the-color-of-a-single-bar-when-the-bar-plot-is-based-on
discard if symbolic/.style 2 args={
filter discard warning=false,
x filter/.code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\ifx\tempa\tempb
\def\pgfmathresult{inf}
\fi
}
},
discard if not symbolic/.style 2 args={
filter discard warning=false,
x filter/.code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\ifx\tempa\tempb
\else
\def\pgfmathresult{inf}
\fi
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment