11

I would like to know if there is a way to specify axis cs to be the default coordinate system inside a plot in PGFPlots, so I don't have to type axis cs: in front of every coordinate pair. Here's a MWE that shows what I mean (the actual plot is irrelevant).

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[
              xmin=0,
              xmax=80,
              ymin=0,
              ymax=80,
              grid=major,
             ]
  \fill [green, opacity=0.5] (axis cs:14,14) -- (axis cs:80,47) -- (axis cs:80,80) -- (axis cs:47,80) -- cycle;
  \fill [red, opacity=0.5] (0,0) -- (axis cs:80,0) -- (axis cs:80,47) -- (axis cs:14,14) -- (axis cs:47,80) -- (axis cs:0,80) -- cycle;
  \draw [thick] (axis cs:47,80) -- (axis cs:14,14) -- (axis cs:80,47);
 \end{axis}
\end{tikzpicture}

\end{document}
nemarona
  • 959
  • 7
  • 17

1 Answers1

13

The current stable version of pgfplots is version 1.11 (released August 2014). It supports this if you write \pgfplotsset{compat=1.11} into your preamble. Without this statement, it will remain compatible with the old behavior.

\documentclass{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=1.11}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[
              xmin=0,
              xmax=80,
              ymin=0,
              ymax=80,
              grid=major,
             ]
  \fill [green, opacity=0.5] (14,14) -- (80,47) -- (80,80) -- (47,80) -- cycle;
  \fill [red, opacity=0.5] (0,0) -- (80,0) -- (80,47) -- (14,14) -- (47,80) -- (0,80) -- cycle;
  \draw [thick] (47,80) -- (14,14) -- (80,47);
 \end{axis}
\end{tikzpicture}

\end{document}

enter image description here