60 lines
1.6 KiB
Plaintext
60 lines
1.6 KiB
Plaintext
# -*- mode: snippet -*-
|
|
# contributor : Pierre Neidhardt <ambrevar at gmail dot com> 2012-08-22
|
|
# key: plotgen
|
|
# group: tikz
|
|
# name: plot generator
|
|
# --
|
|
\newcommand{\\${1}}[7]{
|
|
|
|
\begin{figure}[h!]
|
|
\caption{#1}
|
|
\begin{center}
|
|
\begin{tikzpicture}[scale=0.5,x=1cm,y=0.15cm]
|
|
|
|
%% User parameters.
|
|
\def\xmin{0}
|
|
\def\xmax{10}
|
|
\def\ymin{0}
|
|
\def\ymax{60}
|
|
\def\xstep{1}
|
|
\def\ystep{10}
|
|
|
|
%% Grid
|
|
\draw[style=help lines, ystep=\ystep, xstep=\xstep] (\xmin,\ymin) grid
|
|
(\xmax,\ymax);
|
|
|
|
%% Axes
|
|
\draw[->] (\xmin,\ymin) -- (\xmax+0.5*\xstep,\ymin)
|
|
node[below,yshift=-1em] {#2};
|
|
|
|
\draw[->] (\xmin,\ymin) -- (\xmin,\ymax+0.5*\ystep)
|
|
node[above] {#3};
|
|
|
|
%% xticks and yticks
|
|
\foreach \x in {\xmin,\xstep,...,\xmax}
|
|
\node at (\x, \ymin) [below] {\x};
|
|
\foreach \y in {\ymin,\ystep,...,\ymax}
|
|
\node at (\xmin,\y) [left] {\y};
|
|
|
|
%% DATA
|
|
%% Example from file.
|
|
%% Smooth the curve and mark the data point with a dot.
|
|
%% Data should be stored as
|
|
%% x1 y1
|
|
%% x2 y2
|
|
% \draw[color=blue]
|
|
% plot[smooth,mark=*,mark size=1pt, id=iter_sorted]
|
|
% file {#5}
|
|
% node [right] {#4};
|
|
|
|
%% Example trendline
|
|
%% \draw[color=orange,domain=\xmin+\xstep:\xmax]
|
|
%% plot[smooth, raw gnuplot, id=trend3]
|
|
%% function{f(x)=a*x*log(x)+b; fit f(x) '#5' via a,b; plot f(x)}
|
|
%% node [right,yshift=1em] {$\alpha_1 \cdot n\cdot \log(n) + \beta_1$};
|
|
$0
|
|
\end{tikzpicture}
|
|
\end{center}
|
|
\end{figure}
|
|
}
|