6

I'm using pgfplots for simple plotting 2-dimensional data from a plain datatable file. What i try is to "stretch" the y-axis by a factor (say currently i have stretched it by factor '1' which is the standard and i want to modify that factor (im my case increase it a bit))

Here is a minimal working example:

\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}

I'm looking for a as easy as possible solution which also works in the beamer environment.

12

There's an axis option called y post scale for this:

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.