I try to plot a step-wise function from a series of points, and I have the commands:
pacificpoints = {{-5, 2}, {-4.8, 6}, {-4.5, 3}, {-4.2, 14.5}, {-4,
5}, {-3.8, 8}, {-3.5, 5}, {-3.2, 12}, {-3.1, 10.5}, {-3,
13}, {-2.2, 2}, {-1.9, 11}, {-1.7, 5}, {-1.3, 9.8}, {-0.8, 2}, {0,
25.5}, {0.4, 1}, {0.6, 9}, {1.2, 6}, {1.5, 7.5}, {1.9,
1.8}, {2.2, 7}, {2.5, 4}, {3, 13}, {3.5, 5.5}, {3.8, 10}, {4.2,
4}, {4.5, 8}, {4.8, 5.5}, {5, 1}};
Remove[pacificfun]
The step-wise function is then prepared as:
pacificfun[x_] :=
Piecewise[
Table[{pacificpoints[[i, 2]], pacific[[i, 1]] > x}, {i,
Length[pacificpoints]}], 0];
Plot[pacificpoints[x], {x, -5, 5}, PlotRange -> Full]
But I get only a blank plot, while it works on another quite similar point-set:
alwynpoints = {{-5, 0}, {-4.5, 1.5}, {-4, 0}, {-3.8, -2}, {-3.2,
0}, {-3, 2}, {-2.8, -1.7}, {-2.0, 0}, {-1.8, 2}, {-1.6, 0}, {-1.2,
3.5}, {-1, -3.8}, {-0.5, 0}, {0, 14}, {0.8, -5}, {1, 0}, {1.5,
5}, {1.8, 0}, {2, -5}, {2.2, 0}, {2.5, 4.5}, {2.8,
0}, {3, -3}, {3.5, 0}, {4, 2}, {4.2, 0}, {4.5, -2}, {5, 0}};
I have checked the pacific data set, but nothing is wrong with it.
Any ideas how to plot this as piecewise?
Thanks
pacificfun
contains the undefined arraypacific
. Replacingpacific
bypacificpoints
gives a reasonable plot. $\endgroup$