The Problem
I am trying to split a data set into multiple parts - thanks to help in the past, this has been done before into 2 parts, but I would like to extend this functionality into multiple parts (though the example uses 3). I suspect my problem is how I've used SplitBy
.
Here I am intending to split the graph into multiple parts and draw a dashed line on the graph joining the last and first point of each part. And be able to still calculate average etc.
Additionally the average current figure seems to display as a fraction rather than a decimal - I tried NumberForm
to fix it but it made no change.
The Code
dataSet = {{1000, 5}, {1500, 10}, {2000, 12}, {3000, 17}, {3601,
31}, {4010, 40}, 4050, 44};
{set[1], set[2], set[3]} =
SplitBy[dataSet, #[[1]] < 1850 & , #[[2]] > 1850 & <
3200 &, #[[3]] > 3200 &];
avgCurrent =
Integrate[
Interpolation[dataSet, InterpolationOrder -> 1][x], {x,
dataSet[[1, 1]], dataSet[[-1, 1]]}]/(Subtract @@
dataSet[[{-1, 1}, 1]]);
maxCurrent = MaximalBy[dataSet, Last][[1, 2]];
noPoints = Length[dataSet];
lifeTime = dataSet[[-1, 1]];
ListLinePlot[{set[1], set[2], set[3]},
PlotRange -> {{0, 6000}, {0, 25}},
PlotStyle -> {Directive[RGBColor[0., 0.75, 0.85],
AbsoluteThickness[2.5]]}, PlotTheme -> "Detailed",
Epilog -> {{Dashed, Line[{{1500, 10`}, {2000, 12`}}]}, {Dashed,
Line[{{3000, 17`}, {3601, 31`}}]}, {Red, AbsolutePointSize[4],
Point[dataSet]},
Inset[Framed[
Grid[{{"Average Current: ", avgCurrent,
" \[Mu]A"}, {"Maximum Current: ", maxCurrent,
" \[Mu]A"}, {"Active Cathode Lifetime: ", lifeTime,
"minutes"}, {"Number of Data Points: ", noPoints}}],
Background -> White, RoundingRadius -> 5], Scaled[{.85, .9}]]},
PlotLabel -> "Element (Cathode ?) - Current Yield",
PlotLegends ->
Placed[LineLegend[{"Cathode ? - Element"},
LegendFunction -> "Panel"], {0.85, 0.5}],
LabelStyle -> {Black, Bold}, Frame -> {{True, False}, {True, False}},
FrameLabel -> {"Cathode Runtime (minutes)", "Current (\[Mu]A)"},
ImageSize -> {850, 550}, InterpolationOrder -> 1]
The Output (The Relevant Bit - I think)
A series of errors, leading with...
Part::partw: Part 2 of #1 does not exist. SplitBy::argt: SplitBy called with 3 arguments; 1 or 2 arguments are expected.
Thanks in advance for any help