Merge pull request #88 from rchurchley/pgfplots

Split off and document pgfplots theme
This commit is contained in:
Matthias Vogelgesang 2015-06-17 16:59:58 +02:00
commit 6e4102614a
5 changed files with 218 additions and 122 deletions

View File

@ -152,6 +152,13 @@
\else
\PackageWarning{beamerthemem}{You need to compile with XeLaTeX or LuaLaTeX for the Fira fonts.}
\fi
\AtEndPreamble{%
\@ifpackageloaded{pgfplots}{%
\RequirePackage{pgfplotsthemetol}
}{}
}
% \end{macrocode}
%
% Make Titlepage
@ -517,123 +524,6 @@
}
% \end{macrocode}
%
% pgfplots
%
% Colors
%
% TolColors from http://www.r-bloggers.com/the-paul-tol-21-color-salute/
% \begin{macrocode}
\definecolor{TolColor1}{HTML}{332288} % dark purple
\definecolor{TolColor2}{HTML}{6699CC} % dark blue
\definecolor{TolColor3}{HTML}{88CCEE} % light blue
\definecolor{TolColor4}{HTML}{44AA99} % light green
\definecolor{TolColor5}{HTML}{117733} % dark green
\definecolor{TolColor6}{HTML}{999933} % dark brown
\definecolor{TolColor7}{HTML}{DDCC77} % light brown
\definecolor{TolColor8}{HTML}{661100} % dark red
\definecolor{TolColor9}{HTML}{CC6677} % light red
\definecolor{TolColor10}{HTML}{AA4466} % light pink
\definecolor{TolColor11}{HTML}{882255} % dark pink
\definecolor{TolColor12}{HTML}{AA4499} % light purple
% \end{macrocode}
%
% Color cycles
%
% \begin{macrocode}
\pgfplotscreateplotcyclelist{mbarplot cycle}{%
{draw=TolColor2, fill=TolColor2!70},
{draw=TolColor7, fill=TolColor7!70},
{draw=TolColor4, fill=TolColor4!70},
{draw=TolColor11, fill=TolColor11!70},
{draw=TolColor1, fill=TolColor1!70},
{draw=TolColor8, fill=TolColor8!70},
{draw=TolColor6, fill=TolColor6!70},
{draw=TolColor9, fill=TolColor9!70},
{draw=TolColor10, fill=TolColor10!70},
{draw=TolColor12, fill=TolColor12!70},
{draw=TolColor3, fill=TolColor3!70},
{draw=TolColor5, fill=TolColor5!70},
}
\pgfplotscreateplotcyclelist{mlineplot cycle}{%
{TolColor2, mark=*, mark size=1.5pt},
{TolColor7, mark=square*, mark size=1.3pt},
{TolColor4, mark=triangle*, mark size=1.5pt},
{TolColor6, mark=diamond*, mark size=1.5pt},
}
% \end{macrocode}
%
% Styles
%
% \begin{macrocode}
\pgfplotsset{
compat=1.9,
mbaseplot/.style={
legend style={
draw=none,
fill=none,
cells={anchor=west},
},
x tick label style={
font=\footnotesize
},
y tick label style={
font=\footnotesize
},
legend style={
font=\footnotesize
},
major grid style={
dotted,
},
axis x line*=bottom,
},
mlineplot/.style={
mbaseplot,
xmajorgrids=true,
ymajorgrids=true,
major grid style={dotted},
axis x line=bottom,
axis y line=left,
legend style={
cells={anchor=west},
draw=none
},
cycle list name=mlineplot cycle,
},
mbarplot base/.style={
mbaseplot,
bar width=6pt,
axis y line*=none,
},
mbarplot/.style={
mbarplot base,
ybar,
xmajorgrids=false,
ymajorgrids=true,
area legend,
legend image code/.code={%
\draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
},
cycle list name=mbarplot cycle,
},
horizontal mbarplot/.style={
mbarplot base,
xmajorgrids=true,
ymajorgrids=false,
xbar stacked,
area legend,
legend image code/.code={%
\draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
},
cycle list name=mbarplot cycle,
},
disable thousands separator/.style={
/pgf/number format/.cd,
1000 sep={}
},
}
% \end{macrocode}
%
%
% \begin{macrocode}
\mode<all>
@ -660,7 +550,6 @@
% \begin{macrocode}
\linespread{1.15}
% \end{macrocode}
%
% \iffalse
%</package>

View File

@ -265,11 +265,23 @@ The |\plain{title=[]}{<body>}| command sets a slide in plain dark colors which
can be useful to focus attention on a single sentence or image.
\subsection{pgfplot styles}
\subsection{Paul Tol's colors: a \texttt{pgfplots} theme}
The beamer theme also contains pre-defined pgfplot styles. Use the |mlineplot|
key to plot line data and |mbarplot| or horizontal |mbarplot| to plot bar
charts.
A good presentation uses colors that are
\begin{itemize}
\item distinct from each other as much as possible, and
\item distinct from black and white,
\item under many different lighting and display environments, and
\item to color-blind viewers,
\item all while matching well together.
\end{itemize}
In a \href{https://personal.sron.nl/~pault/colourschemes.pdf}{technical note}
for SRON, Paul Tol proposed a palette of colors satisfying these constraints.
The sub-package |pgfplotsthemetol| defines palettes for |pgfplots| charts
based on Tol's work. Use the |mlineplot| key to plot line data and |mbarplot|
or horizontal |mbarplot| to plot bar charts.
\section{Known Issues}
@ -296,5 +308,6 @@ For a full list of contributors please visit the
\DocInput{beamerthemem.dtx}
\DocInput{beamerfontthememetropolis.dtx}
\DocInput{beamercolorthememetropolis.dtx}
\DocInput{pgfplotsthemetol.dtx}
\end{document}

View File

@ -38,6 +38,9 @@ International License (https://creativecommons.org/licenses/by-sa/4.0/).
\generate{\file{beamercolorthememetropolis.sty}{%
\from{beamercolorthememetropolis.dtx}{package}}
}
\generate{\file{pgfplotsthemetol.sty}{%
\from{pgfplotsthemetol.dtx}{package}}
}
\obeyspaces
\Msg{**************************************************************}
@ -48,6 +51,7 @@ International License (https://creativecommons.org/licenses/by-sa/4.0/).
\Msg{* beamerthemem.sty *}
\Msg{* beamerfontthememetropolis.sty *}
\Msg{* beamercolorthememetropolis.sty *}
\Msg{* pgfplotsthemetol.sty *}
\Msg{* *}
\Msg{* To produce the documentation run the file mtheme.dtx *}
\Msg{* through LaTeX. *}

Binary file not shown.

190
pgfplotsthemetol.dtx Normal file
View File

@ -0,0 +1,190 @@
% \iffalse meta-comment -------------------------------------------------------
% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of
% contributors can be found at
%
% https://github.com/matze/mtheme/graphs/contributors
%
% and these colors were inspired by the Paul Tol 21-color Salute by Peter Carl.
%
% http://www.r-bloggers.com/the-paul-tol-21-color-salute/
%
% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
% International License (https://creativecommons.org/licenses/by-sa/4.0/).
% ------------------------------------------------------------------------- \fi
% \iffalse
%<driver> \ProvidesFile{pgfplotsthemetol.dtx}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pgfplotsthemetol}
[2015/06/16 PGFplots colors based on Paul Tol's SRON technical note]
%</package>
%<driver> \documentclass{ltxdoc}
%<driver> \usepackage{pgfplotsthemetol}
%<driver> \begin{document}
%<driver> \DocInput{pgfplotsthemetol.dtx}
%<driver> \end{document}
% \fi
% \CheckSum{0}
% \StopEventually{}
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
%
% \subsection{\texttt{pgfplotsthemetol}}
%
% Paul Tol's 12-color palette\footnote{Tol actually describes several
% palettes; these colours are taken from the bottom row of Figure 3 in his
% technical note.} is as follows:
%
% \begin{macrocode}
\definecolor{TolDarkPurple}{HTML}{332288}
\definecolor{TolDarkBlue}{HTML}{6699CC}
\definecolor{TolLightBlue}{HTML}{88CCEE}
\definecolor{TolLightGreen}{HTML}{44AA99}
\definecolor{TolDarkGreen}{HTML}{117733}
\definecolor{TolDarkBrown}{HTML}{999933}
\definecolor{TolLightBrown}{HTML}{DDCC77}
\definecolor{TolDarkRed}{HTML}{661100}
\definecolor{TolLightRed}{HTML}{CC6677}
\definecolor{TolLightPink}{HTML}{AA4466}
\definecolor{TolDarkPink}{HTML}{882255}
\definecolor{TolLightPurple}{HTML}{AA4499}
% \end{macrocode}
%
% To use these colors, we describe ``cycle lists'' from which PGF chooses
% styles for the different series in a chart.
%
% \begin{macro}{mbarplot cycle}
% Colors and styles intended for bar charts with up to 12 series.
%
% \begin{macrocode}
\pgfplotscreateplotcyclelist{mbarplot cycle}{%
{draw=TolDarkBlue, fill=TolDarkBlue!70},
{draw=TolLightBrown, fill=TolLightBrown!70},
{draw=TolLightGreen, fill=TolLightGreen!70},
{draw=TolDarkPink, fill=TolDarkPink!70},
{draw=TolDarkPurple, fill=TolDarkPurple!70},
{draw=TolDarkRed, fill=TolDarkRed!70},
{draw=TolDarkBrown, fill=TolDarkBrown!70},
{draw=TolLightRed, fill=TolLightRed!70},
{draw=TolLightPink, fill=TolLightPink!70},
{draw=TolLightPurple, fill=TolLightPurple!70},
{draw=TolLightBlue, fill=TolLightBlue!70},
{draw=TolDarkGreen, fill=TolDarkGreen!70},
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{mlineplot cycle}
% Colors and styles intended for line charts with up to 4 series.
% \begin{macrocode}
\pgfplotscreateplotcyclelist{mlineplot cycle}{%
{TolDarkBlue, mark=*, mark size=1.5pt},
{TolLightBrown, mark=square*, mark size=1.3pt},
{TolLightGreen, mark=triangle*, mark size=1.5pt},
{TolDarkBrown, mark=diamond*, mark size=1.5pt},
}
% \end{macrocode}
% \end{macro}
%
% However, the above cycle lists are not applied automatically. We still need
% to define styles --- |mlineplot| and |mbarplot| --- that the user can apply
% to the axis of a |pgfplots| chart to use the colors. We'll also take the
% opportunity to adjust the display of chart axes when these styles are used.
%
% \begin{macrocode}
\pgfplotsset{
compat=1.9,
% \end{macrocode}
%
% \begin{macro}{mlineplot}
% A style to apply to the axis of a PGF line plot.
% \begin{macrocode}
mlineplot/.style={
mbaseplot,
xmajorgrids=true,
ymajorgrids=true,
major grid style={dotted},
axis x line=bottom,
axis y line=left,
legend style={
cells={anchor=west},
draw=none
},
cycle list name=mlineplot cycle,
},
% \end{macrocode}
% \end{macro}
% \begin{macro}{mbarplot}
% \begin{macro}{horizontal mbarplot}
% A style to apply to the axis of a PGF bar chart. |mbarplot| uses vertical
% bars by default, while |horizontal mbarplot| has horizontal bars as the
% name implies. Their shared properties are factored out into the internal
% style |mbarplot base|.
%
% \begin{macrocode}
mbarplot base/.style={
mbaseplot,
bar width=6pt,
axis y line*=none,
},
mbarplot/.style={
mbarplot base,
ybar,
xmajorgrids=false,
ymajorgrids=true,
area legend,
legend image code/.code={%
\draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
},
cycle list name=mbarplot cycle,
},
horizontal mbarplot/.style={
mbarplot base,
xmajorgrids=true,
ymajorgrids=false,
xbar stacked,
area legend,
legend image code/.code={%
\draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
},
cycle list name=mbarplot cycle,
},
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{mbaseplot}
% Adjusts the appearance of the axes in a PGF chart.
% \begin{macrocode}
mbaseplot/.style={
legend style={
draw=none,
fill=none,
cells={anchor=west},
},
x tick label style={
font=\footnotesize
},
y tick label style={
font=\footnotesize
},
legend style={
font=\footnotesize
},
major grid style={
dotted,
},
axis x line*=bottom,
},
disable thousands separator/.style={
/pgf/number format/.cd,
1000 sep={}
},
}
% \end{macrocode}
% \end{macro}
% \iffalse
%</package>
% \fi
% \Finale
\endinput