%20%E9%96%93%E3%81%AE%E7%9B%B8%E4%BA%92%E4%BD%9C%E7%94%A8.png)
を使用しながらプロット内の領域をシェーディングしたいのですaxes equal=true
が、シェーディングされるはずだった部分の一部がシェーディングされていません。これが私のMWEです。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
axis equal=true,
axis lines=middle,
axis on top,
ticks=none,
xmin=-3,xmax=3,
ymin=-3,ymax=3,
]
\addplot[draw=none,fill=gray!20!white] (-3,-3) -- (-1.125,-3) -- (0.375,3) -- (-3,3) -- cycle;
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
そしてこれが私が得た出力です
何らかの理由で、 を使用するとequal axis=true
x 軸がxmin
値を超えて拡張され、陰影領域が小さくなりすぎます。ただし、equal axis=true
命令をコメント アウトすると、陰影領域は希望どおりに表示されます (ただし、equal axis=true
描画する垂線が実際に垂直に見えるようにするには、命令が必要です)。
答え1
pgfplots マニュアルには次のように記載されています (セクション 4.10.1 共通スケーリング オプション、強調は筆者による):
/pgfplots/axis equal={true,false}
各単位ベクトルは、軸の寸法が一定のまま、同じ長さに設定されます。その後、x と y の各単位のサイズ比は同じになります。
軸の制限が拡大されるスケーリング効果を補正するため。
つまり、xmin
設定は尊重されません。マニュアルには例の後に次のように記載されています。
構成は
axis equal=true
実際には設定する単なるスタイルですunit vector ratio=1 1 1, unit rescale keep size=true
。
見上げるunit rescale keep size
:
/pgfplots/unit rescale keep size=true|false|unless limits declared
デフォルト設定では、単位ベクトル比に異なるスケーリングが関係する場合でも、pgfplots は元の軸の寸法を維持します。これは、制限を拡大することによって行われます。
これを に設定すると、変更がunless limits declared
防止されますxmin
。この設定 ( と組み合わせて) が実際に等しい軸を作成するかどうかは 100% 確信はありませんunit vector ratio=1 1 1
が、機能しているようです。コード:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
%axis equal=true,
unit vector ratio=1 1 1,
unit rescale keep size=unless limits declared,
axis lines=middle,
axis on top,
ticks=none,
xmin=-3,xmax=3,
ymin=-3,ymax=3,
]
\addplot[draw=none,fill=gray!20!white] (-3,-3) -- (-1.125,-3) -- (0.375,3) -- (-3,3) -- cycle;
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}