5

May I know how to draw the graph as shown below? enter image description here

below is a code I have try but with look and feel that is quite far away from the example:

\begin{tikzpicture}
\begin{axis}[
    legend pos=north west,
    width=6cm
]
\addplot plot coordinates {
(2, 48)
(3,336)
(4,2048)
(5, 11520)
(6, 61440)
(7, 315392)
};

\addplot plot coordinates {
(2, 37)
(3, 275)
(4,1726)
(5, 9953)
(6, 55387)
(7, 297786)
};

\addplot plot coordinates {
(2, 43)
(3,252)
(4, 1421)
(5, 7256)
(6, 37561)
(7,181679)
};

\legend{Unreduced, Symmetric, Asymmetric}
\end{axis}
\end{tikzpicture}
william007
  • 4,781
  • Which detail is the problem? – percusse Nov 19 '12 at 15:33
  • The look and feel of the graph is the problem. I am not sure pgf plot can achieve that – william007 Nov 19 '12 at 15:36
  • Can you provide the data or the functions for this? Looks like this is something that can be done via pgfplots. – percusse Nov 19 '12 at 15:37
  • @william007 So give us what you've come up with already and then we can advise you on how to fix up the look and feel. (Which is so vague a term, it's not clear it's useful.) – Alan Munn Nov 19 '12 at 15:37
  • Hi, thanks for the question, I do not have the data, by some data will do, the important thing is how it can display 100-1000 with 100 differents on x-axis, but with exponential of 10 on the y axis, how does it display the x label and ylabel in such a way that closed the axis, and how do we adjust the label reference on the top left corner, and how it display the name(qws dataset) on top of the axis. – william007 Nov 19 '12 at 15:45
  • 1
    If you can add a minimal working example (MWE) we can work on it and give you a sufficient answer. But you should not expect us to setup a complete problem from scratch. Answering the questions are fun but setting up the problems are not. The main answer is using a semilogyaxis environment. – percusse Nov 19 '12 at 15:56
  • Hi I have edited the plot I have now. – william007 Nov 19 '12 at 16:00

2 Answers2

6

pgfplots relies extensively on key=value system. So initially it's a little frustrating to find the correct key. However, the basics are very easy to set up. For this particular example, there are various options that you have to set to match the given figure. Here is a starter :

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
{
% http://tex.stackexchange.com/questions/50313/everymath-and-set-font-for-math
\everymath{\mathsf{\xdef\mysf{\mathgroup\the\mathgroup\relax}}\mysf}

\begin{tikzpicture}[font=\sffamily]
\begin{semilogyaxis}[title=\textbf{QWS Dataset},
    legend pos=outer north east,xtick={1,...,10},
        scaled ticks=false,
        log ticks with fixed point,
    width=7cm,
        ylabel = Computation Time (msec),
        xlabel = Number of Service Candidates Per Class
]
\addplot plot coordinates {(2, 48)(3,336)(4,2048)(5, 11520)(6, 61440)(7,1315392)};
\addplot plot coordinates {(2, 37)(3, 275)(4,1726)(5, 9953)(6, 55387)(7, 297786)};
\addplot plot coordinates {(2, 43)(3,252)(4, 1421)(5, 7256)(6, 37561)(7,81679)};
\legend{Unreduced, Symmetric, Asymmetric}
\end{semilogyaxis}
\end{tikzpicture}
}
\end{document}

enter image description here

percusse
  • 157,807
  • Thanks, have some further question here: http://tex.stackexchange.com/questions/83379/make-the-label-surrounding-line-dissapear – william007 Nov 19 '12 at 17:27
0

Pgfplot can do exactly the same look & fell; it's just a matter of parameters...

I suggest you to search in the manual for the terms logarithmic plots and semilogyaxis in order to draw your y axis.

For the markers and the colors, I suggest you to read the chapter Markers, Linestyle, (Background-) Colors and Colormaps

Edit: manual of pgfplots