# How to add points on the empirical distribution function on the leftside of the pieces (steps)?

Faced the problem. Here is code:

data = Sort[
Sin[(b - a)*RandomVariate[UniformDistribution[{0, 1}], n] + a]];
ScriptCapitalD = EmpiricalDistribution[data];
Plot[CDF[ScriptCapitalD, x], {x, 0, 1}, PlotStyle -> Orange, ExclusionsStyle -> {Dashed}]


And it plots this:

How can i add points on the leftside of each peace of it? Here is example of what i want:

Perhaps you could add point to each line segment after the plot is generated:

SeedRandom[4];
data = Sort[Sin[2*RandomVariate[UniformDistribution[{0, 1}], 12] + 0]];
ScriptCapitalD = EmpiricalDistribution[data];
Plot[CDF[ScriptCapitalD, x], {x, 0, 1}, PlotStyle -> Orange,
ExclusionsStyle -> None, Frame -> True] /.
Line[p_] :> {PointSize[0.015], Point[First@p], Line[p]}


• Thanks a lot, but look: i.imgur.com/D12kb8n.png Is it bug or i have to fix it? I mean, it should go up to point (1, 1). May 13, 2015 at 20:00
• And one more question: how can i add horizontal lines [y = 0, {x, -Inf, 0}] and [y = 1, {x, 1, +Inf}]? May 13, 2015 at 20:08
• @instajke The same issue came up here earlier today: mathematica.stackexchange.com/q/83375 - The simplest fix is to make the plot domain {x, 0, 1.001} and perhaps set PlotRange -> All. May 13, 2015 at 20:09
• @Micahel E2, i meant this: i.imgur.com/5G78tqt.png May 13, 2015 at 20:16
• @instajke Like this?: Show[Plot[CDF[ScriptCapitalD, x], {x, -1, 2}, PlotStyle -> Orange, ExclusionsStyle -> None, Frame -> True] /. Line[p_] :> {PointSize[0.015], Point[First@p], Line[p]}, PlotRange -> {{-0.02, 1.02}, All}] -- Plot more than you need and then chop it off with Show using a restricted PlotRange. It gets rid of the dot at the origin, which I assumed you wanted. May 13, 2015 at 20:22
SeedRandom[123]
n = 15; a = 0; b = 2;
data = Sort[Sin[RandomVariate[UniformDistribution[{a, b}], n]]];


Yo can also specify the PlotStyle setting to add Point primitives to Lines:

Plot[CDF[EmpiricalDistribution[data], y], {y, 0, 1}, Filling -> None,
PlotStyle -> ({Orange, Thick, #, PointSize[.0125],
Point[#[[1]]] & @@ #} &), ImageSize -> 500, PlotRange -> {0, 1}]


You can also use, perhaps more transparently, PlotStyle -> ({Orange, Thick, #, PointSize[.0125], # /. Line -> Composition[Point, First]} &).

Alternatively,

Plot[CDF[EmpiricalDistribution[data], y], {y, 0, 1}, Filling -> None,
PlotStyle -> ({Orange, Thick, #, PointSize[.0125],
Point[#[[1]]] & @@ #, PointSize[.005], White,
Point[#[[1]]] & @@ #} &), ImageSize -> 500, PlotRange -> {0, 1}]


• That is great. I've often wanted PlotStyle to accept a function, but have never seen it in the docs. That should be better known. Is there a guide to usage somewhere? Does it work on 3D plots? (+1) May 13, 2015 at 20:14