3

The code:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=1.2]
  \begin{axis}[
    title=Find next vertex,
    xlabel=Cube's $dimension$,
    ylabel=$Time$ (sec),]
    \addplot coordinates {
        (2, 4.86e-07)
    (4, 1.548e-06)
    (8, 2.1081e-05)
    (16, 0.00440496)
    (32, 277.778)
    };
    \addplot [red,mark=*]  coordinates {
        (2, 8.17e-07)
    (4, 2.218e-06)
    (8, 3.0043e-05)
    (16, 0.00721884)
    (32, 296.945)    
    };
  \end{axis}
\end{tikzpicture}
\end{document}

The result:

enter image description here

As you, the first four measurements seem to be equal (which is not the real case) and this happens because the last measurement is significantly larger. Any idea how to cope with this problem?


By using log scale the small values distinguish, but the big ones collide. Maybe I should zoom-in, but no idea how to apply this in my case!

  • Put a break in the y-axis perhaps. – JPi Feb 24 '17 at 3:15
  • What is a break @JPi? Could you please provide an example? – gsamaras Feb 24 '17 at 10:01
  • I would just use log scale. @JPi probably means something like tex.stackexchange.com/a/62778/586 – Torbjørn T. Feb 24 '17 at 19:01
  • Hmm @TorbjørnT. I think log scale is the way here too...You can a post an answer if you like! – gsamaras Feb 24 '17 at 19:15
  • Please post complete examples people can compile - don't make people guess how to complete you code, which is a pain and quite unreliable. – cfr Feb 25 '17 at 1:38
3

Considering that the y-values span 8 orders of magnitude, I'd say a logarithmic scale is the way to go here. Also, don't use math mode for italic text, it's semantically wrong, and gives bad output. If you need italic, use \textit{dimension}.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[scale=1.2]
  \begin{axis}[
    title=Find next vertex,
    xlabel=Cube's dimension,
    ylabel=Time (sec),
    ymode=log]
    \addplot coordinates {
        (2, 4.86e-07)
    (4, 1.548e-06)
    (8, 2.1081e-05)
    (16, 0.00440496)
    (32, 277.778)
    };
    \addplot [red,mark=*]  coordinates {
        (2, 8.17e-07)
    (4, 2.218e-06)
    (8, 3.0043e-05)
    (16, 0.00721884)
    (32, 296.945)    
    };
  \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.