%--------------------------------------------
%
% Package pgfplots
%
% Provides a user-friendly interface to create function plots (normal
% plots, semi-logplots and double-logplots).
% 
% It is based on Till Tantau's PGF package.
%
% Copyright 2007/2008 by Christian Feuersänger.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------

\writestatus{loading}{ConTeXt User Module / Pgfplots}

\unprotect

\input pgfplots.revision.tex
\startmodule [pgfplots]

% regarding the t-prefix: ensure that we do not accidentally load the plain tex tikz.tex file...
\usemodule[t][tikz]
\usetikzlibrary[plotmarks]

\edef\tikzatcode{\the\catcode`\@}
\edef\tikzbarcode{\the\catcode`\|}
\edef\tikzexclaimcode{\the\catcode`\!}
\catcode`\@=11
\catcode`\|=12
\catcode`\!=12



\input pgfplots.code.tex

\def\pgfplotsincludegraphics[#1]#2{\externalfigure[#2][#1]}
\pgfkeys{/pgfplots/plot graphics/includegraphics cmd=\pgfplotsincludegraphics}


\let\pgfplots@ORIG@tikz@installcommands@before@context=\tikz@installcommands

\def\tikz@installcommands{%
	\pgfplots@ORIG@tikz@installcommands@before@context
	%
	\let\startaxis=\pgfplots@environment@axis
	\let\stopaxis=\endpgfplots@environment@axis
	%
	\let\startsemilogxaxis=\pgfplots@environment@semilogxaxis
	\let\stopsemilogxaxis=\endpgfplots@environment@semilogxaxis
	%
	\let\startsemilogyaxis=\pgfplots@environment@semilogyaxis
	\let\stopsemilogyaxis=\endpgfplots@environment@semilogyaxis
	%
	\let\startloglogaxis=\pgfplots@environment@loglogaxis
	\let\stoploglogaxis=\endpgfplots@environment@loglogaxis
	%
	\def\startpgfplotsinterruptdatabb{\pgfplotsinterruptdatabb}%
	\def\stoppgfplotsinterruptdatabb{\endpgfplotsinterruptdatabb}%
}%

\catcode`\@=\tikzatcode
\catcode`\|=\tikzbarcode
\catcode`\!=\tikzexclaimcode

\stopmodule

\protect
\endinput
