0
$\begingroup$

I have two large datasets to plot histograms and their PDFs. The code used is the following:

<< eNpop.dat;
Arand = Map[Sort, eNpop, {2}];
AArand = Cases[Arand, {_, _, _, _, _}, 2];
A1rand = N @ Flatten[Map[(#[[1]]) &, AArand]];
<< eFPSpop.dat;
Afps = Map[Sort, eFPSpop, {2}];
AAfps = Cases[Afps, {_, _, _, _, _}, 2];
A1fps = N @ Flatten[Map[(#[[1]]) &, AAfps]];
eϕ1rand = 
 FindDistribution[A1rand, TargetFunctions -> "Continuous", 
  PerformanceGoal -> "Quality"];
A1fps = N @ Flatten[Map[(#[[1]]) &, AAfps]];
eϕ1fps = 
 FindDistribution[A1fps, TargetFunctions -> "Continuous", 
  PerformanceGoal -> "Quality"];

Show[Legended[
  Histogram[
   <|"RAND" -> A1rand, "FPS" -> A1fps|>
   , {10}, "PDF", 
   PlotRange -> {{0, 350}, All}, PlotTheme -> "Scientific", 
   ChartStyle -> 96, 
   ChartBaseStyle -> Directive[EdgeForm[None], Opacity[0.25]], 
   FrameLabel -> {"Time", "Probability"}], Placed[
   SwatchLegend[96, {"No stigmergy", "FPS"}], {0.9, 0.8}]],
 Plot[{Callout[PDF[eϕ1rand, x], 
    "FrechetDistribution (α=0.9, β=65.3, μ=-6.7)", \
{150, 0.0075}, 40, CalloutMarker -> "CirclePoint"],
   PDF[eϕ1fps, x]
   }, {x, 0, 350}, PlotStyle -> Thick, PlotRange -> All], 
 ImageSize -> 600]

The datasets eNpop.datand eFPSpop.dat can be downloaded from

(the two data sets)

The code above it works fine with the one Calloutbut it does not work if I try to put a second Calloutfor the second PDF function.

How could I set the two Calloutsin the same plot?

Besides, I want to include this figure in a publication. How could I improve it?. I have been testing Histogram options with no clear better results.

$\endgroup$

1 Answer 1

4
$\begingroup$

As stated in the comments to your previous question on this topic, you need to upgrade from v11.0.0 to v11.0.1

$Version

(*  "11.0.1 for Mac OS X x86 (64-bit) (September 21, 2016)"  *)

<< /Users/roberthanlon/Downloads/datasets/eNpop.dat;

<< /Users/roberthanlon/Downloads/datasets/eFPSpop.dat;

Arand = Map[Sort, eNpop, {2}];
AArand = Cases[Arand, {_, _, _, _, _}, 2];
A1rand = N@Flatten[Map[(#[[1]]) &, AArand]];
Afps = Map[Sort, eFPSpop, {2}];
AAfps = Cases[Afps, {_, _, _, _, _}, 2];
A1fps = N@Flatten[Map[(#[[1]]) &, AAfps]];
eϕ1rand = 
  FindDistribution[A1rand, TargetFunctions -> "Continuous", 
   PerformanceGoal -> "Quality"];
A1fps = N@Flatten[Map[(#[[1]]) &, AAfps]];
eϕ1fps = 
  FindDistribution[A1fps, TargetFunctions -> "Continuous", 
   PerformanceGoal -> "Quality"];

Note that your Callout had the wrong parameters for the FrechetDistribution

Show[
 Legended[
  Histogram[<|"RAND" -> A1rand, "FPS" -> A1fps|>, {10}, "PDF",
   PlotRange -> {{0, 350}, All},
   PlotTheme -> "Scientific",
   ChartStyle -> 96,
   ChartBaseStyle -> Directive[EdgeForm[None], Opacity[0.25]],
   FrameLabel -> {"Time", "Probability"}], 
  Placed[LineLegend[96, {"No stigmergy", "FPS"}], {0.9, 0.85}]],
 Plot[{
   Callout[PDF[eϕ1rand, x],
    StringForm["FrechetDistribution (α=`1`, β=`2`, μ=`3`)",
     Sequence @@ (NumberForm[#, {3, 1}] & /@ eϕ1rand)],
    {150, 0.007}, 50,
    CalloutMarker -> "CirclePoint"],
   Callout[PDF[eϕ1fps, x], StringReplace[ToString[eϕ1fps],
     {"{Cauchy" -> "\n{Cauchy", "Inverse" -> "\nInverse"}],
    {190, 0.01}, 65,
    CalloutMarker -> "CirclePoint"]},
  {x, 0, 350},
  PlotStyle -> Thick,
  PlotRange -> All],
 ImageSize -> 600]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you, I have upgraded Mathematica to 11.0.1 version and it works. I would like this figure to look prettier because I want to include it in a publication. How could I improve it?. I have been testing Histogram options with no clear better results. (I am going to add this part in the question). Regards. $\endgroup$ Apr 4, 2017 at 8:13
  • $\begingroup$ @user1993416 - Rapidly accepting an answer and adding to the question are counterproductive. An accepted answer is less likely to get further attention. Also, "How could I improve it?" is vague/subjective and requires any reader to try and guess what you would consider to be an improvement. You could start by reformatting the Callout for the MixtureDistribution. You should be able to do that using the other one as an example and referring to the documentation. Why is the left axis labeled "Probability" when you are plotting "Probability Density"? $\endgroup$
    – Bob Hanlon
    Apr 4, 2017 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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