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 am a beginner with the package TikZ. I am using pgfplots to produce a very simple plot. The code I am using has been copied from an example found on the web, but my output is different from the example I saw.

This is the code:

\pgfplotsset{   width=0.45\linewidth,
             xmin=0,xmax=100,
             ymin=0,ymax=1,
             grid=major
            }
\begin{tikzpicture}
\begin{axis}[
    xlabel=Percentage,
    ylabel=Accuracy]
    \addplot[smooth,mark=*,blue] plot coordinates {
    (11,0.6)
(15,    0.71)
(19,    0.7)
(25,    0.74)
(32,    0.73)
(40,    0.78)
(50,    0.81)
(51,    0.79)
(55,    0.79)
(56,    0.79)
(58,    0.77)
(61,    0.77)
(69,    0.77)
};
\addlegendentry{legend}
[...]

In the output the labels of the axis ticks are too close to the line. Is there any way to move the farther away? [I cannot post an image because my reputation is too low]

I have read the manual and checked other questions, but I cannot find the option/command I need to use.

Could you please help me?


While writing the minimal example as requested in the comments, I discovered that I see that problem only when the document class is baposter. With the article class it works ok.

The minimal working example with class baposter follows:

\documentclass[a0paper,portrait]{baposter}

\usepackage{graphicx}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

  \begin{poster}{
    grid=false, 
    colspacing=0.7em,
    eyecatcher=false, 
    bgColorOne=white,
    background=plain,
   } %poster
   % eyecatcher
   {

   }
   % title
   {
    TITLE
   }
   %Authors
   {
    AUTHORS
   }
   % Logo
   {

   }

  \headerbox{header}{name=header,column=0,row=0,span=4}{ 
    \pgfplotsset{width=0.45\linewidth,
             xmin=0,xmax=100,
             ymin=0,ymax=1,
             grid=major
            }
    \begin{tikzpicture}
      \begin{axis}[
        xlabel=p,
        ylabel=a]
        \addplot[smooth,mark=*,blue] plot coordinates {
            (11, 0.6)
            (15, 0.71)
            (19, 0.7)
            (25, 0.74)

        };
        \addlegendentry{legend}
      \end{axis}
    \end{tikzpicture}
} % headerbox

\end{poster}

\end{document}
share|improve this question
    
Hi Antonio, welcome to the site! I can't reproduce this, unfortunately. Could you turn your code snippet into a complete minimal example document, so starting from \documentclass and including all the options that are necessary to reproduce the problem (and only those)? –  Jake Feb 13 '13 at 10:21
    
Hello, thanks for the answer. I discovered that there is no problem when using the article class. I was using the class baposter: I posted a minimal example with that document class. –  Antonio Sesto Feb 13 '13 at 14:03

2 Answers 2

up vote 2 down vote accepted

This happens because the baposter class puts all its contents into a tikzpicture with the option inner sep=0pt, outer sep=0pt, which is passed on to your tikzpicture, causing the tick label nodes to be printed without any padding. You can reset the padding by adding inner sep=0.333em, outer sep=0.5\pgflinewidth to your tikzpicture options (those are the default values):

\documentclass[a0paper,portrait]{baposter}

\usepackage{graphicx}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

  \begin{poster}{
    grid=false, 
    colspacing=0.7em,
    eyecatcher=false, 
    bgColorOne=white,
    background=plain,
   } %poster
   % eyecatcher
   {

   }
   % title
   {
    TITLE
   }
   %Authors
   {
    AUTHORS
   }
   % Logo
   {

   }

  \headerbox{header}{name=header,column=0,row=0,span=4}{ 
    \pgfplotsset{width=0.45\linewidth,
             xmin=0,xmax=100,
             ymin=0,ymax=1,
             grid=major
            }
    \begin{tikzpicture}[inner sep=0.3333em, outer sep=0.5\pgflinewidth]
      \begin{axis}[
        xlabel=p,
        ylabel=a]
        \addplot[smooth,mark=*,blue] plot coordinates {
            (11, 0.6)
            (15, 0.71)
            (19, 0.7)
            (25, 0.74)

        };
        \addlegendentry{legend}
      \end{axis}
    \end{tikzpicture}
} % headerbox

\end{poster}

\end{document}
share|improve this answer
    
Thank you very much. Indeed, it is the first time I am using baposter and tikz. –  Antonio Sesto Feb 13 '13 at 15:05

You could use nodes instaed of xlabel and ylabel. You can place the nodes where you want by defining the right position.

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks, arrows, shapes, backgrounds, shadows, positioning, calc, fit}

\begin{document}


\pgfplotsset{   width=0.45\linewidth,
             xmin=0,xmax=100,
             ymin=0,ymax=1,
             grid=major
            }
\begin{tikzpicture}
\begin{axis}[
    %xlabel=Percentage,
    %ylabel=Accuracy
        ]
    \addplot[smooth,mark=*,blue] plot coordinates {
    (11,0.6)
(15,    0.71)
(19,    0.7)
(25,    0.74)
(32,    0.73)
(40,    0.78)
(50,    0.81)
(51,    0.79)
(55,    0.79)
(56,    0.79)
(58,    0.77)
(61,    0.77)
(69,    0.77)
};

\end{axis}

\node at (1.5cm,-0.8cm) {Percentage};
\node at (-1cm,1.5cm) [rotate=90, anchor=base] {Acccuracy};
\end{tikzpicture}

\end{document}
share|improve this answer

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.