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 have the pgf plots below, where it doesn't appear well. I wish to

  1. put closer the "Solving Time(ms)" and y axis,
  2. put the font size smaller how should i do it?

There is also a problem for cramping up the number in the right chart, is there a way not to display every number so that the number do not cramping up?

\documentclass[9pt]{sig-alternate}
% GRAPHICS
\usepackage{pgf}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows,automata,positioning}
\begin{document}
\pgfplotsset{
xticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},
every axis/.append style={
font=\sffamily,
  width=6.5cm,
    height=4.9cm
}
}
\begin{figure*}[t]
\begin{minipage}{0.5\linewidth}
\centering
\scriptsize
 \begin{tikzpicture}[font=\sffamily]
\begin{semilogyaxis}[title=\textbf{ Dataset 1},
    legend pos=outer north east,
        legend style={draw=none},
        xtick={50,100,150,200,250,300,350,400,450,500},
    scaled ticks=false,
    log ticks with fixed point={1000 sep=},
        axis x line=bottom,
    axis y line=left,
        axis line style=-,
        minor tick style={draw=none},
        enlargelimits,
        ylabel = Solving Time (ms),
        xlabel = Service Class Size
]
\addplot plot coordinates{(50,77)(100,81)(150,109)(200,155)(250,112)(300,139)(350,175)(400,214)(450,206)(500,228)};
\addplot plot coordinates{(50,10)(100,1)(150,2)(200,2)(250,1)(300,1)(350,1)(400,2)(450,1)(500,1)};
\addplot plot coordinates{(50,2)(100,2)(150,2)(200,2)(250,2)(300,1)(350,1)(400,2)(450,1)(500,1)};
\addplot plot coordinates{(50,3)(100,1)(150,1)(200,1)(250,1)(300,1)(350,1)(400,1)(450,1)(500,1)};
\addplot plot coordinates{(50,5)(100,1)(150,2)(200,1)(250,1)(300,1)(350,1)(400,1)(450,1)(500,1)};
\legend{$a$,$b$,$c$,$d$,$e$}
\end{semilogyaxis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\linewidth}
\centering
\scriptsize
 \begin{tikzpicture}[font=\sffamily]
\begin{semilogyaxis}[title=\textbf{ Dataset 2},
    legend pos=outer north east,
        legend style={draw=none},
        xtick={500,1000,1500,2000,2500,3000,3500,4000,4500,5000},
    scaled ticks=false,
    log ticks with fixed point={1000 sep=},
        axis x line=bottom,
    axis y line=left,
        axis line style=-,
        minor tick style={draw=none},
        enlargelimits,
        ylabel = Solving Time (ms),
        xlabel = Service Class Size
]
\addplot plot coordinates{(500,35)(1000,1048)(1500,1668)(2000,2309)(2500,2918)(3000,3965)(3500,5008)(4000,5569)(4500,5833)(5000,6680)};
\addplot plot coordinates{(500,855)(1000,1613)(1500,1878)(2000,2228)(2500,2738)(3000,2480)(3500,2512)(4000,3263)(4500,3746)(5000,4676)};
\addplot plot coordinates{(500,80)(1000,90)(1500,62)(2000,77)(2500,54)(3000,49)(3500,33)(4000,45)(4500,34)(5000,68)};
\addplot plot coordinates{(500,101)(1000,633)(1500,302)(2000,151)(2500,138)(3000,35)(3500,41)(4000,57)(4500,20)(5000,42)};
\addplot plot coordinates{(500,20)(1000,66)(1500,79)(2000,74)(2500,81)(3000,45)(3500,57)(4000,45)(4500,27)(5000,17)};
\legend{$a$,$b$,$c$,$d$,$e$}
\end{semilogyaxis}
\end{tikzpicture}
\end{minipage}
\end{figure*}
 \end{document} 

enter image description here

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Here's the output from the code below

enter image description here

I changed a few things, which you'll see I've tagged with % new bit

  • I moved \pgfplotsset into the preamble
  • I removed some of the surplus packages- pgfplots loads tikz, pgf, and graphicx, so there's no need to load them explicitly
  • I removed \scriptsize from each individual picture, and put it in \pgfplotsset so that the changes are global
  • I removed textbf from your individual titles and created a style in pgfplotsset in the preamble (this will ease global changes in the future)
  • I removed [font=\sffamily] from \begin{tikzpicture}[font=\sffamily] as it is specified globally in the preamble now
  • I changed xtick in each of the pictures, to make the labels a little less cluttered
  • I moved the ylabel closer to the axis using ylabel shift=-2pt, which requires compat=1.3 or newer
  • I added a % after your first \end{minipage}; this is very important as it removes the additional space that a minipage inserts, and removes the Overfull hbox warning that you got

Code

\documentclass[9pt]{sig-alternate}
\usepackage{pgfplots}

\pgfplotsset{
    compat=1.3,
    xticklabel={$\mathsf{\pgfmathprintnumber{\tick}}$},
    every axis/.append style={
        font=\sffamily,
        label style={font=\scriptsize\sffamily}, % new bit
        legend style={font=\scriptsize\sffamily},% new bit
        title style={font=\bfseries\sffamily}, % new bit
        width=6.5cm,
        height=4.9cm,
        ylabel shift=-2pt, % new bit
    }
}


\begin{document}

\begin{figure*}[t]
    \begin{minipage}{0.5\linewidth}
        \centering
        \begin{tikzpicture}
            \begin{semilogyaxis}[title=Dataset 1,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={50,150,...,500}, % new bit
                scaled ticks=false,
                log ticks with fixed point={1000 sep=},
                axis x line=bottom,
                axis y line=left,
                axis line style=-,
                minor tick style={draw=none},
                enlargelimits,
                ylabel = Solving Time (ms),
                xlabel = Service Class Size
                ]
                \addplot plot coordinates{(50,77)(100,81)(150,109)(200,155)(250,112)(300,139)(350,175)(400,214)(450,206)(500,228)};
                \addplot plot coordinates{(50,10)(100,1)(150,2)(200,2)(250,1)(300,1)(350,1)(400,2)(450,1)(500,1)};
                \addplot plot coordinates{(50,2)(100,2)(150,2)(200,2)(250,2)(300,1)(350,1)(400,2)(450,1)(500,1)};
                \addplot plot coordinates{(50,3)(100,1)(150,1)(200,1)(250,1)(300,1)(350,1)(400,1)(450,1)(500,1)};
                \addplot plot coordinates{(50,5)(100,1)(150,2)(200,1)(250,1)(300,1)(350,1)(400,1)(450,1)(500,1)};
                \legend{$a$,$b$,$c$,$d$,$e$}
            \end{semilogyaxis}
        \end{tikzpicture}
    \end{minipage}% new bit
    \begin{minipage}{0.5\linewidth}
        \centering
        \begin{tikzpicture}
            \begin{semilogyaxis}[title=Dataset 2,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={500,1500,...,4500}, % new bit
                scaled ticks=false,
                log ticks with fixed point={1000 sep=},
                axis x line=bottom,
                axis y line=left,
                axis line style=-,
                minor tick style={draw=none},
                enlargelimits,
                ylabel = Solving Time (ms),
                xlabel = Service Class Size
                ]
                \addplot plot coordinates{(500,35)(1000,1048)(1500,1668)(2000,2309)(2500,2918)(3000,3965)(3500,5008)(4000,5569)(4500,5833)(5000,6680)};
                \addplot plot coordinates{(500,855)(1000,1613)(1500,1878)(2000,2228)(2500,2738)(3000,2480)(3500,2512)(4000,3263)(4500,3746)(5000,4676)};
                \addplot plot coordinates{(500,80)(1000,90)(1500,62)(2000,77)(2500,54)(3000,49)(3500,33)(4000,45)(4500,34)(5000,68)};
                \addplot plot coordinates{(500,101)(1000,633)(1500,302)(2000,151)(2500,138)(3000,35)(3500,41)(4000,57)(4500,20)(5000,42)};
                \addplot plot coordinates{(500,20)(1000,66)(1500,79)(2000,74)(2500,81)(3000,45)(3500,57)(4000,45)(4500,27)(5000,17)};
                \legend{$a$,$b$,$c$,$d$,$e$}
            \end{semilogyaxis}
        \end{tikzpicture}
    \end{minipage}
\end{figure*}
\end{document} 

As a final comment- there are a lot of features that common to both plots, such as

            scaled ticks=false,
            log ticks with fixed point={1000 sep=},
            axis x line=bottom,
            axis y line=left,
            axis line style=-,
            minor tick style={draw=none},
            enlargelimits,

If these are true in every single plot that you draw in this document, then you might like to consider putting these into your global pgfplotsset as well.

In general, try and use styles where ever possible- it eases both code readability and global changes, and is one of the many reasons to use tikz :)

share|improve this answer
    
+1 yticklabels are still in serif fonts. Four digit numbers shouldn't have a thousand separator. –  Luigi Nov 24 '12 at 19:48
add comment

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.