Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm a tikz-pgf beginner and try to do two simple things:

  1. i have x-values between 2^20 and 2^30 (the size, always a power of two). How can i modify the xticks respectivly (not having a power of ten)?
  2. each and very y-value should be divided by (size/1024) automatically (in gnuplot it would look like: ($8):($9/($8/1024)), iff $8:=size and $9:=time)

My minimal code example looks like:

    \documentclass{minimal}
    \usepackage{pgfplots}
    \begin{document}

    \begin{tikzpicture}
    \begin{axis} [
      xmode = log,
      xlabel=size in bytes,
      ylabel=time in $\frac{s}{KiB}$ 
      ]

      \pgfplotstableread{datafile}
      \datatable

      \addplot table[x = size, y = time] from \datatable ;

    \end{axis}
    \end{tikzpicture}

    \end{document}

What's the simplest way to do this?

share|improve this question
    
Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say "thank you" to users who helped you. –  Claudio Fiandrino Mar 26 '13 at 13:03
    
@Claudio Fiandrino good to know, i will make sure to avoid this in future posts –  bobb_the_builder Mar 26 '13 at 22:37

1 Answer 1

up vote 5 down vote accepted

You can use the log basis x key to define the logarithm with respect to 2.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}

\begin{tikzpicture}
\begin{axis} [
  xmode = log,
  log basis x=2,
  xlabel=size in bytes,
  ylabel=time in $\frac{s}{KiB}$ 
  ]

  %\pgfplotstableread{datafile}
  %\datatable

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

enter image description here

share|improve this answer
    
\pgfplotsset{compat=newest} would be a bit more universal, just to increase compatibility with different versions of pgfplots. –  bobb_the_builder Mar 26 '13 at 14:13
1  
@bobb_the_builder It would make your code prone to breakdowns if a new version removes an existing feature. It's a good practice to keep the compat to the version you have made the code. As it happend here just today tex.stackexchange.com/questions/104349/… :) –  percusse Mar 26 '13 at 14:14
    
ouch, sorry, good point! (+1) –  bobb_the_builder Mar 26 '13 at 14:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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