pgfplots の背景を色付けするオプション

pgfplots の背景を色付けするオプション

私はこれに対する簡単な答えを探していましたが、うまくいきませんでした。関数 y=x^2 をプロットし、環境によって構成されるボックス全体の背景に色を付けたいです。直感的には、 のオプションが利用できるとaxis思われますが、そうではないことがわかりました。これには簡単な解決策はありませんか? また、ボックスの外側に色を拡張したい場合はどうすればよいですか。fillaxisaxis

もちろん、手動で長方形を追加し、必要に応じてその寸法を調整することもできますが、これは便利ではありません。

\documentclass{article}
\usepackage{tikzplot}
\begin{document}
   \begin{tikzpicture}
      \begin{axis}[fill = grey!10,] % This option does not work, why????
         \addplot {x^2};
      \end{axis}

   \end{tikzpicture}
\end{document} 

答え1

pgfplots ドキュメントの 95 ページから。環境axis background/.styleには を使用してくださいaxis

ここに画像の説明を入力してください

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
   \begin{tikzpicture}
      \begin{axis}[axis background/.style={fill=gray!10}]
         \addplot {x^2};
      \end{axis}
   \end{tikzpicture}
\end{document}

関連情報