0
$\begingroup$

Consider the following plot:

CDFforPoisson[u_] = x /. Solve[Exp[-x/0.01] == u, x][[1]]; DistrData = CDFforPoisson@RandomReal[{0, 1}, 10^6]; Histogram[{DistrData}, 100, "ProbabilityDensity", Frame -> True, ChartStyle -> {Opacity[.25, Red], Opacity[.25, Blue], Opacity[.25, Darker@Green]}, FrameStyle -> Directive[Black, 18], ScalingFunctions -> {"Log", "Log"}, ImageSize -> Large, PlotRange -> {{0.0001, 0.03}, All}, FrameLabel -> {"\!\(\*SubscriptBox[\(l\), \(\(displ\)\(.\)\)]\) \ [mm]", "Fraction"}, PlotLabel -> Style[Row[{"\!\(\*SubscriptBox[\(l\), \(decay\)]\) = 0.01 mm"}], 18, Black], ChartLegends -> Placed[{"Before IP"}, {0.2, 0.9}]] 

enter image description here

It has two problems: small font of legends, and a bin going out of the plot frame (on the right). Could you please tell me how to adjust the font of the legend, and how to avoid the frame problem?

$\endgroup$
2
  • 1
    $\begingroup$ For the legend size try e.g. Placed[{Style["Before IP", 16]}, ...] where 16 is the font size. $\endgroup$ Commented Nov 1, 2022 at 15:04
  • $\begingroup$ How is CDFforPoisson related to a Poisson distribution? The only thing I can come up with is that CDFforPoisson[u] gives one-hundredth of the mean of a Poisson distribution whose probability of obtaining zero is u. Also, Solve is not necessary as the result is - Log[u]/100. $\endgroup$ Commented Nov 1, 2022 at 17:43

2 Answers 2

2
$\begingroup$
  1. Using PlotRangePadding, space can be created around the histogram.
  2. Using LegendMarkerSize for a SwatchLegend, the size of the legend can be changed. You can also use Style as has been suggested without altering your code much.

Histogram[{DistrData}, 100, "ProbabilityDensity" , Frame -> True , ChartStyle -> { Opacity[.25, Red] , Opacity[.25, Blue] , Opacity[.25, Darker@Green] } , FrameStyle -> Directive[Black, 18] , ScalingFunctions -> {"Log", "Log"}, ImageSize -> Large , PlotRange -> {{0.0001, 0.03}, All} , PlotRangePadding -> {{2, 0.1}, {2, 0.1}} , FrameLabel -> {"\!\(\*SubscriptBox[\(l\), \(\(displ\)\(.\)\)]\) \ [mm]", "Fraction"}, PlotLabel -> Style[Row[{"\!\(\*SubscriptBox[\(l\), \(decay\)]\) = 0.01 mm"}], 18, Black], ChartLegends -> Placed[SwatchLegend[{Directive[Opacity[0.25], Red]}, {"Before IP"} , LegendMarkerSize -> 30], {0.2, 0.9}] ] 

enter image description here

$\endgroup$
1
$\begingroup$

I'm not understanding the use of the term "CDF" in the function CDFforPoisson as the equation being Solved is related to the probability of a zero for a Poisson distribution and it doesn't need Solve in that CDFforPoisson could be written as

CDFforPoisson[u_]:=-Log[u]/100 

If u has a uniform distribution, then the pdf of $-\log(u)/100$ is known and no random samples are necessary:

dist = TransformedDistribution[-Log[u]/100, u \[Distributed] UniformDistribution[{0, 1}]] (* ExponentialDistribution[100] *) PDF[dist, x] 

PDF of exponential distribution with parameter = 100

I'm not seeing the need to use a log scale for either horizontal or vertical axis. Also, the vertical axis represents the "probability density" which is not a "Fraction" (or a percentage) as labeled.

Am I totally not understanding the question?

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.