# Mathematica StackedList Plot error : An option must be a rule or a list of rules [closed]

I am trying to plot the given equation as a StackedListPlot. It works normally when I use the Plot function but does not work when I use the StackedList Plot.


params = {c -> 1, e -> .1, u -> .5, m -> 0.001, q -> .2};
fig1a = StackedListPlot[{1/(
2 c d (c + d - q)) (c^2 d + c d^2 + 2 c^2 e + c d e - d^2 e +
c^2 m + c d m - 2 c d q - c e q + d e q - c m q + d m q +
c^2 u + c d u -
c Sqrt[-4 d m (-c + e + m) (c + d -
q) + (d (e + 2 m) - (e + m) q + c (-d + 2 e + m + u))^2] -
d Sqrt[-4 d m (-c + e + m) (c + d -
q) + (d (e + 2 m) - (e + m) q +
c (-d + 2 e + m + u))^2]) /. params, (
c d - 2 c e - d e - c m - 2 d m + e q + m q - c u +
Sqrt[-4 d m (-c + e + m) (c + d - q) + (d (e + 2 m) - (e + m) q +
c (-d + 2 e + m + u))^2])/(2 d (c + d - q)) /. params}, {d,
0, 2} , PlotStyle -> {Blue, Red}, PlotRange -> {0, 1}]



I am getting the error

An option must be a rule or a set of rules

• It would have been clearer if you quoted the whole error: "options expected (instead of {d,0,2})...". This is a ListPlot: you should provide it numerical values only. You can't specify a range for the independent variable. Use Plot instead of StackedListPlot and you'll get your result. Commented Jun 6, 2023 at 12:03

ClearAll[func]
func[d_] := {1/(2 c d (c + d - q)) (c^2 d + c d^2 + 2 c^2 e + c d e -
d^2 e + c^2 m + c d m - 2 c d q - c e q + d e q - c m q +
d m q + c^2 u + c d u - c Sqrt[-4 d m (-c + e + m) (c + d - q) +
(d (e + 2 m) - (e + m) q + c (-d + 2 e + m + u))^2] -
d Sqrt[-4 d m (-c + e + m) (c + d - q) + (d (e + 2 m) -
(e + m) q + c (-d + 2 e + m + u))^2]),
(c d - 2 c e - d e - c m - 2 d m + e q +
m q - c u + Sqrt[-4 d m (-c + e + m) (c + d - q) +
(d (e + 2 m) - (e + m) q + c (-d + 2 e + m + u))^2])/(2 d (c + d - q))} /.
params;


You can use Plot (as suggested by MarcoB in comments) processing with Accumulate the two components of func[d]:

Plot[Evaluate @ Accumulate @ func[d], {d, 0, 2}, PlotStyle -> {Blue, Red},
PlotRange -> {0, 1}, Filling -> {1 -> Axis, 2 -> {1}}]


If you have to use StackedListPlot, use func[d] to generate a data set that StackedListPlot will accept:

slpdata = Transpose@Table[func[d], {d, 10^-4, 2, .05}];

StackedListPlot[slpdata,
PlotStyle -> {Blue, Red}, PlotRange -> {0, 1}, DataRange -> {0, 2}]