3

I'm trying to plot the beta prime distribution, which is defined for x>0 with the two parameters α and β, having the probability density function:

enter image description here

I'm trying to plot a graph like this:

enter image description here

see https://en.wikipedia.org/wiki/Beta_prime_distribution

This is what I have so far:

enter image description here

I can't get the colours to work, even though I am using cycle list name as shown in this question - pgfplots line colors

MWE:

\documentclass[a4paper]{article}
\usepackage{pgfplots}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}

\begin{axis}[
%
xmin=0,xmax=5,
ymin=0,ymax=2,
cycle list name = auto,
samples=100]

\foreach \A/\B/\C in {%
    1/1/1,
    1/2/0.5,
    2/1/0.5,
    2/2/0.1667,
    2/3/0.0833,
    5/3/0.009524}{%
\addplot[domain=0:5] {((x^(\A-1))*(1+x)^(-\A-\B))/\C};
}
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}
  • 2
    I've just realised the thing that was missing was a + after \addplot – John Mar 7 at 15:44
3

I think that it is possible if you insert a cycle of color: here there is your revised MWE. The symbols %<------ correspond to my additions.

enter image description here

\documentclass[a4paper]{article}
\usepackage{pgfplots}
\pgfplotscreateplotcyclelist{fycle}{%  %<------
    {blue}, %<------
    {orange},%<------
    {red},%<------
    {green},%<------
}%<------

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}

\begin{axis}[
%
xmin=0,xmax=5,
ymin=0,ymax=2,
cycle list name = fycle,
samples=100]

\foreach \A/\B/\C in {%
    1/1/1,
    1/2/0.5,
    2/1/0.5,
    2/2/0.1667,
    2/3/0.0833,
    5/3/0.009524}{%
\addplot+[domain=0:5] {((x^(\A-1))*(1+x)^(-\A-\B))/\C};%<------ only %\addplot+
}
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.