commit 23a62869be9ced4fcbb17a711f7e5811f43815ae Author: Andreas Tsouchlos Date: Wed Dec 20 23:40:59 2023 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/.latexmkrc b/.latexmkrc new file mode 100644 index 0000000..fd022f6 --- /dev/null +++ b/.latexmkrc @@ -0,0 +1,2 @@ +$pdflatex="pdflatex -shell-escape -interaction=nonstopmode -synctex=1 %O %S"; +$out_dir = 'build'; diff --git a/common.tex b/common.tex new file mode 100644 index 0000000..5160ff6 --- /dev/null +++ b/common.tex @@ -0,0 +1,258 @@ +% Author: Andreas Tsouchlos +% +% Collection of useful commands and definitions +% +% ||====================================================================|| +% || WARNING || +% ||====================================================================|| +% || || +% || The following packages have to be included before using this file: || +% || amsmath || +% || pgfplots || +% ||====================================================================|| + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Math Symbols %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\DeclareMathOperator*{\argmin}{\arg\!\min} +\DeclareMathOperator*{\argmax}{\arg\!\max} +\DeclareMathOperator\sign{sign} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Graphics & Plotting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% +% Filters for Pgfplots +% Source: https://tex.stackexchange.com/a/58563 (modified) +% + +\pgfplotsset{ + discard if/.style 2 args={ + x filter/.append code={ + \edef\tempa{\thisrow{#1}} + \edef\tempb{#2} + \ifx\tempa\tempb + \def\pgfmathresult{inf} + \fi + } + }, + discard if not/.style 2 args={ + x filter/.append code={ + \edef\tempa{\thisrow{#1}} + \edef\tempb{#2} + \ifx\tempa\tempb + \else + \def\pgfmathresult{inf} + \fi + } + }, + discard if gt/.style 2 args={ + x filter/.append code={ + \edef\tempa{\thisrow{#1}} + \edef\tempb{#2} + \ifdim\tempa pt > \tempb pt + \def\pgfmathresult{inf} + \fi + } + }, + discard if lt/.style 2 args={ + x filter/.append code={ + \edef\tempa{\thisrow{#1}} + \edef\tempb{#2} + \ifdim\tempa pt < \tempb pt + \def\pgfmathresult{inf} + \fi + } + } +} + +% +% Styles +% + + +\pgfplotsset{ + fancy marks/.style={ + % TODO + } +} + +% +% Colors +% + +\definecolor{kit-green100}{rgb}{0,.59,.51} +\definecolor{kit-green70}{rgb}{.3,.71,.65} +\definecolor{kit-green50}{rgb}{.50,.79,.75} +\definecolor{kit-green30}{rgb}{.69,.87,.85} +\definecolor{kit-green15}{rgb}{.85,.93,.93} +\definecolor{KITgreen}{rgb}{0,.59,.51} + +\definecolor{KITpalegreen}{RGB}{130,190,60} +\colorlet{kit-maigreen100}{KITpalegreen} +\colorlet{kit-maigreen70}{KITpalegreen!70} +\colorlet{kit-maigreen50}{KITpalegreen!50} +\colorlet{kit-maigreen30}{KITpalegreen!30} +\colorlet{kit-maigreen15}{KITpalegreen!15} + +\definecolor{KITblue}{rgb}{.27,.39,.66} +\definecolor{kit-blue100}{rgb}{.27,.39,.67} +\definecolor{kit-blue70}{rgb}{.49,.57,.76} +\definecolor{kit-blue50}{rgb}{.64,.69,.83} +\definecolor{kit-blue30}{rgb}{.78,.82,.9} +\definecolor{kit-blue15}{rgb}{.89,.91,.95} + +\definecolor{KITyellow}{rgb}{.98,.89,0} +\definecolor{kit-yellow100}{cmyk}{0,.05,1,0} +\definecolor{kit-yellow70}{cmyk}{0,.035,.7,0} +\definecolor{kit-yellow50}{cmyk}{0,.025,.5,0} +\definecolor{kit-yellow30}{cmyk}{0,.015,.3,0} +\definecolor{kit-yellow15}{cmyk}{0,.0075,.15,0} + +\definecolor{KITorange}{rgb}{.87,.60,.10} +\definecolor{kit-orange100}{cmyk}{0,.45,1,0} +\definecolor{kit-orange70}{cmyk}{0,.315,.7,0} +\definecolor{kit-orange50}{cmyk}{0,.225,.5,0} +\definecolor{kit-orange30}{cmyk}{0,.135,.3,0} +\definecolor{kit-orange15}{cmyk}{0,.0675,.15,0} + +\definecolor{KITred}{rgb}{.63,.13,.13} +\definecolor{kit-red100}{cmyk}{.25,1,1,0} +\definecolor{kit-red70}{cmyk}{.175,.7,.7,0} +\definecolor{kit-red50}{cmyk}{.125,.5,.5,0} +\definecolor{kit-red30}{cmyk}{.075,.3,.3,0} +\definecolor{kit-red15}{cmyk}{.0375,.15,.15,0} + +\definecolor{KITpurple}{RGB}{160,0,120} +\colorlet{kit-purple100}{KITpurple} +\colorlet{kit-purple70}{KITpurple!70} +\colorlet{kit-purple50}{KITpurple!50} +\colorlet{kit-purple30}{KITpurple!30} +\colorlet{kit-purple15}{KITpurple!15} + +\definecolor{KITcyanblue}{RGB}{80,170,230} +\colorlet{kit-cyanblue100}{KITcyanblue} +\colorlet{kit-cyanblue70}{KITcyanblue!70} +\colorlet{kit-cyanblue50}{KITcyanblue!50} +\colorlet{kit-cyanblue30}{KITcyanblue!30} +\colorlet{kit-cyanblue15}{KITcyanblue!15} + +% +% Color Schemes +% + +% Define colormaps + +\pgfplotsset{ + colormap={mako}{ + rgb=(0.18195582, 0.11955283, 0.23136943) + rgb=(0.25307401, 0.23772973, 0.48316271) + rgb=(0.21607792, 0.39736958, 0.61948028) + rgb=(0.20344718, 0.56074869, 0.65649508) + rgb=(0.25187832, 0.71827158, 0.67872193) + rgb=(0.54578602, 0.8544913, 0.69848331) + }, + colormap={rocket}{ + rgb=(0.20973515, 0.09747934, 0.24238489) + rgb=(0.43860848, 0.12177004, 0.34119475) + rgb=(0.67824099, 0.09192342, 0.3504148) + rgb=(0.8833417, 0.19830556, 0.26014181) + rgb=(0.95381595, 0.46373781, 0.31769923) + rgb=(0.96516917, 0.70776351, 0.5606593) + }, + colormap={cividis}{ + rgb=(0.130669, 0.231458, 0.43284) + rgb=(0.298421, 0.332247, 0.423973) + rgb=(0.42512, 0.431334, 0.447692) + rgb=(0.555393, 0.537807, 0.471147) + rgb=(0.695985, 0.648334, 0.440072) + rgb=(0.849223, 0.771947, 0.359729) + }, + colormap={cel}{ + color=(KITred!90!black); + color=(kit-blue100); + color=(kit-green70); + color=(kit-yellow70!80!kit-orange70); + }, +} + +% Define cycle lists + +\pgfplotscreateplotcyclelist{mako}{% + [samples of colormap={4} of mako]% +} +\pgfplotscreateplotcyclelist{rocket}{% + [samples of colormap={4} of rocket]% +} +\pgfplotscreateplotcyclelist{cividis}{% + [samples of colormap={4} of cividis]% +} +\pgfplotscreateplotcyclelist{viridis}{% + [samples of colormap={4} of viridis]% +} +\pgfplotscreateplotcyclelist{cel}{% + [samples of colormap={4} of cel]% +} + +% Define individual colors + +\makeatletter + +\def\extractcolormapcolor#1#2{% + \expandafter\pgfplotscolormapaccess\expandafter[\pgfplotspointmetatransformedrange]% + [1.0]% + {#2}% + {\pgfkeysvalueof{/pgfplots/colormap name}}% + \def\pgfplots@loc@TMPb{\pgfutil@definecolor{#1}{\csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname}}% + \expandafter\pgfplots@loc@TMPb\expandafter{\pgfmathresult}% +}% + +\def\getcolorbyvalue#1{ + \csname pgfpl@cm@\pgfkeysvalueof{/pgfplots/colormap name}@colspace\endcsname +} + +\makeatother + +\def\setschemecolors{ + \extractcolormapcolor{scol0}{0} + \extractcolormapcolor{scol1}{333} + \extractcolormapcolor{scol2}{666} + \extractcolormapcolor{scol3}{1000} +} + +% Define color schemes + +\pgfplotsset{ + /pgfplots/colorscheme/mako/.style={ + colormap name={mako}, + cycle list name={mako}, + /utils/exec={\setschemecolors}, + }, + /pgfplots/colorscheme/rocket/.style={ + colormap name={rocket}, + cycle list name={rocket}, + /utils/exec={\setschemecolors}, + }, + /pgfplots/colorscheme/cividis/.style={ + colormap name={cividis}, + cycle list name={cividis}, + /utils/exec={\setschemecolors}, + }, + /pgfplots/colorscheme/viridis/.style={ + colormap name={viridis}, + cycle list name={viridis}, + /utils/exec={\setschemecolors}, + }, + /pgfplots/colorscheme/cel/.style={ + colormap name={cel}, + cycle list name={cel}, + /utils/exec={\setschemecolors}, + }, +} + diff --git a/example.tex b/example.tex new file mode 100644 index 0000000..af2396c --- /dev/null +++ b/example.tex @@ -0,0 +1,88 @@ +\documentclass{article} + +% Packages necessary for common.tex +\usepackage{amsmath} +\usepackage{pgfplots} +\pgfplotsset{compat=newest} + +% Other packages +\usepackage{float} +\usepackage{subcaption} +\usepackage[a4paper, total={5in, 9in}]{geometry} +\usetikzlibrary{positioning} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%% Set common options %%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\input{common.tex} +\pgfplotsset{colorscheme/cel} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%% Actual Document %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\begin{document} + + +\foreach \x in {cel, rocket, viridis, mako, cividis}{ + \pgfplotsset{colorscheme/\x} + + \colorbox{gray!30}{\texttt{colorscheme/\x}} + \begin{figure}[H] + \centering + + \tikzstyle{colornode} = [draw, inner sep=0pt, minimum width=1cm, minimum height=0.5cm] + \pgfplotsset{scaled y ticks=false} + + \begin{subfigure}[c]{0.45\textwidth} + \begin{tikzpicture} + \begin{axis}[ + domain=0:10, + view={0}{90}, + yticklabel=\empty,xticklabel=\empty, + width=\textwidth, + height=0.75\textwidth, + ] + \addplot3+[surf] + {x + y}; + \end{axis} + \end{tikzpicture} + \end{subfigure}% + \begin{subfigure}[c]{0.45\textwidth} + \begin{tikzpicture} + \begin{axis}[ + domain=0:10, + ymin=-1e4,ymax=1, + legend pos=south west, + yticklabel=\empty,xticklabel=\empty, + width=\textwidth, + height=0.75\textwidth, + ] + \foreach \i in {1,2,4,8}{ + \addplot+ [mark=none, line width=1pt] + {-\i*exp(x)}; + %\expandafter\addlegendentry\expandafter{$e^{-\text{\i} x}$} + \addlegendentryexpanded{$e^{-\i x}$} + } + \end{axis} + \end{tikzpicture} + \end{subfigure}% + \begin{subfigure}[c]{0.1\textwidth} + \begin{tikzpicture} + \node[colornode, fill=scol3] (color3) {}; + \node[colornode, fill=scol2, above=1mm of color3] (color2) {}; + \node[colornode, fill=scol1, above=1mm of color2] (color1) {}; + \node[colornode, fill=scol0, above=1mm of color1] (color0) {}; + \end{tikzpicture} + \end{subfigure}% + \end{figure} +} + + +\end{document} +