10

Using groupplot library of PGFPlots, the command \nextgroupplot can take the parameters that \begin{axis} used to take. So giving it the option "ymode=log" should effectively make the plot a semilogyaxis plot. However I do get an error when I do that:

Missing number, treated as zero.

This is strange because it works find if I gave it xmode=log it runs without errors (although giving an empty plot instead).

The minimum running example follows:

\documentclass[11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}

\usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}[scale=0.6]
    \begin{groupplot}[ group style={group name=my plots, group size=2 by 1}, ymax=1, restrict y to domain=0:1]
      \nextgroupplot[ymode=log]%
      \addplot+[domain=0:6,mark=o,smooth,samples=20] {2^(-1)*exp(x)};%
      \addplot+[domain=0:6,mark=square,smooth,samples=20] {1-((1-2^(-1))/exp(x))};%

      \nextgroupplot%
      \addplot+[domain=0:6,mark=o,smooth,samples=20] {2^(-3)*exp(x)};%
      \addplot+[domain=0:6,mark=square,smooth,samples=20] {1-((1-2^(-3))/exp(x))};%
    \end{groupplot}
  \end{tikzpicture} 
\end{document}

The equations used to plot normally in a semilogyaxis, but I wanted them in a groupplot. So the function domain and so should not be the problem.

1 Answer 1

8

You mustn't restrict the domain for the y axes. The logarithm is not defined for zero. The following works for me.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}

\begin{document}
  \begin{tikzpicture}[scale=0.6]
    \begin{groupplot}[%
      group style={%
        group name={my plots},
        group size=2 by 1
      },
      ymax=1,
%      restrict y to domain=0:1   % <<<<< This is not allowed
    ]
      \nextgroupplot[ymode=log]%
      \addplot+[domain=0:6,mark=o,smooth,samples=20] {2^(-1)*exp(x)};%
      \addplot+[domain=0:6,mark=square,smooth,samples=20] {1-((1-2^(-1))/exp(x))};%
      \nextgroupplot%
      \addplot+[domain=0:6,mark=o,smooth,samples=20] {2^(-3)*exp(x)};%
      \addplot+[domain=0:6,mark=square,smooth,samples=20] {1-((1-2^(-3))/exp(x))};%
    \end{groupplot}
  \end{tikzpicture}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .