
設定したいアスペクト比pgfplots は、幅と高さを明示的に指定せずに (つまり、デフォルトのままにして) プロットします。3D プロットの場合は がありますplot box ratio
。2D プロットの場合は を試してみました\axisdefaultheight
が、バランスが崩れてしまいます。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
width=2\axisdefaultheight
]
\addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
\end{axis}
\end{tikzpicture}
\end{document}
このオプションはunit vector ratio
実際の軸の制限を考慮に入れるので、少し計算すればこれを使用できます。ただし、軸の長さのみの設定を探しています。
何かヒントはありますか?
答え1
\axisdefaultheight
は長さではなく単なるマクロなので、2\axisdefaultheight
機能しませんが、2*\axisdefaultheight
機能します。ただし、幅と高さの両方を指定するのがおそらく最も簡単なオプションです。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0.0, xmax=3.0,
ymin=0.0, ymax=1.0,
scale only axis,
height=\axisdefaultheight,
width=2*\axisdefaultheight
]
\addplot [red]
table {%
0 0
0.1 0.587785252292473
0.2 0.951056516295154
0.3 0.951056516295154
0.4 0.587785252292473
0.5 1.22464679914735e-16
0.6 -0.587785252292473
0.7 -0.951056516295154
0.8 -0.951056516295154
0.9 -0.587785252292473
1 -2.44929359829471e-16
1.1 0.587785252292474
1.2 0.951056516295154
1.3 0.951056516295154
1.4 0.587785252292473
1.5 3.67394039744206e-16
1.6 -0.587785252292473
1.7 -0.951056516295154
1.8 -0.951056516295154
1.9 -0.587785252292473
};
\end{axis}
\end{tikzpicture}
\end{document}