我正在使用 pgfplots 从纯数据表文件中简单绘制二维数据。我尝试将 y 轴“拉伸”一个因子(假设目前我已将其拉伸了因子“1”,这是标准,我想修改该因子(我的情况是将其增加一点))
这是一个最小的工作示例:
\documentclass{article}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.7}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis} [
xmode = log,
log basis x=2,
ytick={2,...,7},
xlabel={Input size $n$},
ylabel={time per input in $s$},
grid=major,
grid style={densely dotted},
legend style={at={(0.425,0.99)},
anchor=north,legend columns=2}
]
]
\addplot table[x = size, y expr= \thisrow{time}/(\thisrow{size}/1024)] {
size time
1048576 1024
8388608 2048
67108864 4096
536870912 8192
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
我正在寻找一个尽可能简单的解决方案,该解决方案也可以在投影机环境中运行。
答案1
有一个名为axis
的选项y post scale
:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis} [
xmode = log,
log basis x=2,
ytick={0,0.5,1},
xlabel={Input size $n$},
ylabel={time per input in $s$},
grid=major,
grid style={densely dotted},
legend style={at={(0.425,0.99)},
anchor=north,legend columns=2},
]
\addplot table[x = size, y expr= \thisrow{time}/(\thisrow{size}/1024)] {
size time
1048576 1024
8388608 2048
67108864 4096
536870912 8192
};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis} [
xmode = log,
log basis x=2,
ytick={0,0.5,1},
xlabel={Input size $n$},
ylabel={time per input in $s$},
grid=major,
grid style={densely dotted},
legend style={at={(0.425,0.99)},
anchor=north,legend columns=2},
y post scale=1.4
]
\addplot table[x = size, y expr= \thisrow{time}/(\thisrow{size}/1024)] {
size time
1048576 1024
8388608 2048
67108864 4096
536870912 8192
};
\end{axis}
\end{tikzpicture}
\end{document}