我的图表中有一些图,我想用正方形标记特殊区域。
剧情如下:
\begin{tikzpicture}
\begin{axis}[axis lines = left, xlabel = {Player 1}, ylabel = {Player 2}, xmin = 0, xmax = 3.5, ymin = 0, ymax = 3.5]
\filldraw [draw=none,pattern=north east lines] (200, 200) rectangle (400, 400);
\addplot [blue, thick]{2};
\addplot [blue, thick] coordinates {(2,0)(2,3.5)};
\addplot [color=red, thick]{-x+3};
\end{axis}
\end{tikzpicture}
图表渲染正确,但我用绿色手工标记的区域没有出现。但是,如果我注释掉三个 addplot 命令,该区域就会神奇地出现:
\begin{tikzpicture}
\begin{axis}[axis lines = left, xlabel = {Player 1}, ylabel = {Player 2}, xmin = 0, xmax = 3.5, ymin = 0, ymax = 3.5]
\filldraw [draw=none,pattern=north east lines] (200, 200) rectangle (400, 400);
% \addplot [blue, thick]{2};
% \addplot [blue, thick] coordinates {(2,0)(2,3.5)};
% \addplot [color=red, thick]{-x+3};
\end{axis}
\end{tikzpicture}
我觉得这像是 bug,但也许我只是缺少一些背景信息来了解它为什么不起作用。有办法解决这个问题吗?
编辑:更新包,\pgfplotsset{compat=1.16}
在文档前添加并替换坐标\filldraw (2, 2) rectangle (4, 4);
似乎可以解决问题。