0
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $Number of Elements$,
ylabel = {$Combinations=\frac{(n)!}{(n-r)!(r!)}$},
]
%Axis
\addplot [
domain=2:10, 
samples=100, 
color=red,
]
%{x!/((x-2)!(2!))};
{ factorial(x)/(factorial(x-2))(factorial(2)))};
\addlegendentry{$\frac{(n)!}{(n-r)!(r!)}$}
\end{axis}
\end{tikzpicture}
6
  • 2
    Welcome to TeX.SX! Your code is very welcome, but it would be best if you could convert it to a minimal working example (MWE). Also, experience suggests that code-only questions are not so easy to answer as those with a textual description of the problem too.
    – Joseph Wright
    Jul 23, 2014 at 6:02
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Adam Liter
    Jul 23, 2014 at 6:02
  • it might be little complicated, as I copied it from my thesis, most likely requires only : \usepackage{pgfplots} \usepackage{tikz} \begin{document}\end{document}. If yet not comprehensive, I can try to create a MWE.
    – Sid
    Jul 23, 2014 at 6:08
  • 1
    @Sid: a minimal working example is not taking stuff from the thesis. It is matter of creating a document that reproduces the problem, the graph in your case. For instance, start with article document class, add pgfplots as a package and include in the document the snippet of code you already provided. That's it. Jul 23, 2014 at 6:15
  • @ClaudioFiandrino:Thanks, I will definitely do it next time. However, PERCUSSE was kind enough to do himself. Can't thank him enough.
    – Sid
    Jul 23, 2014 at 8:38

1 Answer 1

5

Your grouping is not correct and implicit multiplication is not implemented yet.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}%


\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = Number of Elements,
ylabel = {$\mathrm{Combinations}=\frac{(n)!}{(n-r)!(r!)}$},
]
%Axis
\addplot [
domain=2:10, 
samples=100, 
color=red,
]
%{x!/((x-2)!(2!))};
{ factorial(x)/(factorial(x-2)*factorial(2))};
\addlegendentry{$\frac{(n)!}{(n-r)!(r!)}$}
\end{axis}
\end{tikzpicture}
\end{document}
1
  • Thanks a lot, you are indeed right about the braces --- and thanks for pointing out about implicit multiplication. However, when I also tried to use simple factorial(x) the graph was not ascending as expected. 1,1,2,6,24...
    – Sid
    Jul 23, 2014 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .