8

The following MWE

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar,ymode = log]
\addplot coordinates{
(1,1e-15)
(2,1e-14)
(3,1e-13)
};
\end{axis}
\end{tikzpicture}
\end{document}

compiles to this bar chart:

enter image description here

I'd like the bars to start from the bottom of the screen instead of the top, since it makes more sense to visualize my data like that (they are computational errors).

Is there a pgfplots option to achieve that? The manual only says that the bars always start from 0 (and there is no way to change that); clearly, when ymode=log this is interpreted as starting from log(1)=0, which is not what I want here.

  • 1
    You can set log origin=infty to make the bars start from the bottom. – Jake Dec 12 '12 at 10:26
  • Ah, thanks, I missed that on the manual! Wish to post it as an answer for me to accept it? – Federico Poloni Dec 12 '12 at 10:38
11

You can define where the "drawing origin" for logarithmic plots should be by setting log origin to either 0 or infty. If you set it to 0, which is the default, bar plots, comb plots and filled area plots will start from log(1)=0, so in this case the top of the plot. If you set it to infty, the plots will start from the bottom edge of the plot area, which is what you want in this case:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar,ymode = log, log origin=infty]
\addplot coordinates{
(1,1e-15)
(2,1e-14)
(3,1e-13)
};
\end{axis}
\end{tikzpicture}
\end{document}
| improve this answer | |

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.