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 wish to move the legend for the left chart closer to the graph, and for the right graph, I wish to let the x-axis and y-axis appeared just like the left graph (so that there is some extra spaces to the left of 1 and to the right of 9 for x-axis, similar to y-axis), here is the graph and code

enter image description here

\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=Dataset 1,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={1,2,...,9}, % 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{(1,5302)(2,5585)(3,5890)(4,5645)(5,5813)(6,7117)(7,8388)(8,8350)(9,8831)};
\addplot plot coordinates{(1,2)(2,2)(3,2)(4,2)(5,2)(6,3617)(7,2755)(8,2644)(9,3466)};
\addplot plot coordinates{(1,2)(2,3)(3,4)(4,2)(5,3)(6,2341)(7,3320)(8,2298)(9,3183)};
\addplot plot coordinates{(1,1)(2,2)(3,3)(4,2)(5,2)(6,4)(7,4)(8,5)(9,32)};
\addplot plot coordinates{(1,2)(2,2)(3,3)(4,2)(5,2)(6,5)(7,4)(8,4)(9,33)};
\legend{$a$,$b$,$c$,$d$,$e$}
\end{semilogyaxis}
\end{tikzpicture}
\end{minipage}% new bit
\begin{minipage}{0.5\linewidth}
\centering
\scriptsize
 \begin{tikzpicture}[font=\sffamily]
\begin{axis}[title=\textbf{Dataset 2},
    legend pos=outer north east,
                ymin=99.4,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={1,2,...,9},
                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},
        ylabel = Optimality (\%),
        xlabel = Number of Constraints
]
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.84)(8,99.59)(9,99.65)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.44)(7,100)(8,99.78)(9,99.73)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.74)(8,99.74)(9,99.86)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.74)(8,99.74)(9,99.86)};
\legend{$a$,$b$,$c$,$d$}
\end{axis}
\end{tikzpicture}
\end{minipage}%
\end{figure*}
 \end{document} 
share|improve this question
add comment

1 Answer

To move the legend you can use every axis legend/.append style= to introduce an appropriate shift; for the issue with the labels in the plot to the right, you can set enlargelimits=true:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\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=Dataset 1,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={1,2,...,9}, % 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,
               every axis legend/.append style={xshift=-10pt}
                ]
\addplot plot coordinates{(1,5302)(2,5585)(3,5890)(4,5645)(5,5813)(6,7117)(7,8388)(8,8350)(9,8831)};
\addplot plot coordinates{(1,2)(2,2)(3,2)(4,2)(5,2)(6,3617)(7,2755)(8,2644)(9,3466)};
\addplot plot coordinates{(1,2)(2,3)(3,4)(4,2)(5,3)(6,2341)(7,3320)(8,2298)(9,3183)};
\addplot plot coordinates{(1,1)(2,2)(3,3)(4,2)(5,2)(6,4)(7,4)(8,5)(9,32)};
\addplot plot coordinates{(1,2)(2,2)(3,3)(4,2)(5,2)(6,5)(7,4)(8,4)(9,33)};
\legend{$a$,$b$,$c$,$d$,$e$}
\end{semilogyaxis}
\end{tikzpicture}
\end{minipage}% new bit
\begin{minipage}{0.5\linewidth}
\centering
\scriptsize
 \begin{tikzpicture}[font=\sffamily]
\begin{axis}[title=\textbf{Dataset 2},
    legend pos=outer north east,
                ymin=99.4,
                legend pos=outer north east,
                legend style={draw=none},
                xtick={1,2,...,9},
                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},
        ylabel = Optimality (\%),
        xlabel = Number of Constraints,
               enlargelimits=true
]
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.84)(8,99.59)(9,99.65)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.44)(7,100)(8,99.78)(9,99.73)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.74)(8,99.74)(9,99.86)};
\addplot plot coordinates{(1,100)(2,100)(3,100)(4,100)(5,100)(6,99.82)(7,99.74)(8,99.74)(9,99.86)};
\legend{$a$,$b$,$c$,$d$}
\end{axis}
\end{tikzpicture}
\end{minipage}%
\end{figure*}
 \end{document} 

enter image description here

I used

\documentclass{article}
\usepackage[margin=2cm]{geometry}

in my example, since I don't have your document class.

share|improve this answer
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.