
私はこれに対する簡単な答えを探していましたが、うまくいきませんでした。関数 y=x^2 をプロットし、環境によって構成されるボックス全体の背景に色を付けたいです。直感的には、 のオプションが利用できるとaxis
思われますが、そうではないことがわかりました。これには簡単な解決策はありませんか? また、ボックスの外側に色を拡張したい場合はどうすればよいですか。fill
axis
axis
もちろん、手動で長方形を追加し、必要に応じてその寸法を調整することもできますが、これは便利ではありません。
\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}