0

I've got a problem here. When I use the code like its shown below, it all works fine. BUT if I'm changing the xmax parameter to a smaller value like for example xmax=0.05 there are some errors occurring.

! Package pgfkeys Error: I do not know the key '/pgf/number format/at', to which you passed '(1,0)', and I am going to ignore it. Perhaps you misspelled it.See the pgfkeys package documentation for explanation.Type H for immediate help.... \end{axis}

! Package pgfkeys Error: I do not know the key '/pgf/number format/yshift', towhich you passed '-2em', and I am going to ignore it. Perhaps you misspelled it.See the pgfkeys package documentation for explanation.Type H for immediate help.... \end{axis}

! Package pgfkeys Error: I do not know the key '/pgf/number format/left' and Iam going to ignore it. Perhaps you misspelled it.See the pgfkeys package documentation for explanation.Type H for immediate help.... \end{axis}

! Package pgfkeys Error: I do not know the key '/pgf/number format/inner sep',to which you passed '0pt', and I am going to ignore it. Perhaps you misspelledit.See the pgfkeys package documentation for explanation.Type H for immediate help.... \end{axis}

    \documentclass[12pt,a4paper]{report}
    \usepackage[utf8]{inputenc}
    \usepackage[german]{babel}
    \usepackage[T1]{fontenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
    \usepackage{pgfplots}
    \begin{document}

    \begin{figure}
    \centering
    \begin{tikzpicture}
    \pgfplotsset{every axis/.append style={
    font=\footnotesize,
    %line width=1pt,
    %tick style={line width=0.8pt}
    }}
    \pgfplotsset{every axis legend/.append style={at={(0.5,1.03)},anchor=south}}
    \begin{axis}[ticklabel style={
        /pgf/number format/.cd,
  use comma},xlabel={$\sigma$ [-]},ylabel={$\Lambda$ [-]}, grid=major, legend columns=-1, xmin= 0, xmax= 0.1, cycle list name=black white, width= 0.5\textwidth]
    \addplot table {test.dat};
    \legend {Theorie}
    \end{axis}
    \end{tikzpicture}
    \caption[]{}
    \end{figure}

    \end{document}

The data file test.dat looks like:

    x   y
    0.0000734405    1.00
    0.000734224 1.00002
    0.00220151  1.00003
    0.003667276 1.00007
    0.005863111 1.00017
    0.00732515  1.00026
    0.0109739   1.00060
    0.014613779 1.00106
    0.021868115 1.00236
    0.02908885  1.00416

If someone has an idea to scale the diagram to the right size it would realy help me. Any help will be greatly appreciated! Thanks!

0

The first problem occurs, because you are changing the directory (.cd) to the number format, but then you don't switch it back to tikz which causes the above errors. As you easily will agree on, at, yshift, left, and inner sep do not belong to the number format, but are tikz keys.

The second problem can be solved using the scaled ticks feature.

Have a look at the following code and the inlcuded comments for more details. (For simplicity I directly included the data files of test.dat into the document itself.)

\documentclass[border=2mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \pgfplotsset{
            every axis/.append style={
                font=\footnotesize,
                line width=1pt,
                tick style={line width=0.8pt}
            },
            every axis legend/.append style={
                at={(0.5,1.03)},
                anchor=south,
            },
        }
        \begin{axis}[
            % don't scale `xticks'
            scaled x ticks=false,
            % scale `yticks' by subtracting 1 from the value
            % add "+1" as scale label
            % (the `%' signs are needed to avoid plotting unnecessary white space)
            scaled y ticks=manual:{$+1$}{%
                \pgfmathparse{#1-1}%
            },
            ticklabel style={
                % change "directory" to the number format
                /pgf/number format/.cd,
                    use comma,
                    fixed,
                % change "directory" back to tikz
                /tikz/.cd,
            },
            xticklabel style={
                /pgf/number format/precision=2,
            },
            yticklabel style={
                /pgf/number format/precision=3,
            },
            xlabel={$\sigma$ [--]},
            ylabel={$\Lambda$ [--]},
            grid=major,
            legend columns=-1,
            xmin=0,
            xmax=0.05,
            cycle list name=black white,
            width=0.5\textwidth,
        ]
%            \addplot table {test.dat};
            \addplot table {
                x   y
                0.0000734405    1.00
                0.000734224 1.00002
                0.00220151  1.00003
                0.003667276 1.00007
                0.005863111 1.00017
                0.00732515  1.00026
                0.0109739   1.00060
                0.014613779 1.00106
                0.021868115 1.00236
                0.02908885  1.00416
            };
            \legend {Theorie}
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

  • Just for the record: Besides accepting the answer you could also upvote the answer by clicking on the up-arrow above the number on the left side of the answer. – Stefan Pinnow Dec 6 '16 at 22:30

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.