
Я хотел бы установитьсоотношение сторонграфиков 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}