4
$\begingroup$

When I plot the data I have using ListStepPlot and ListLinePlot[data,InterpolationOrder -> 0] I am getting two different plot. I guess there is a bug in ListStepPlot.

data={{{0, 1}, {0.0582215, 2}, {0.597255, 3}, {1.17158, 4}}, {{1.17158, 
   4}, {1.36478, 5}, {1.424, 6}, {1.4586, 7}}, {{1.4586, 7}, {1.73938,
    8}, {1.88332, 9}, {2.03753, 10}}, {{2.03753, 10}, {2.17872, 
   11}, {2.46005, 12}, {2.71547, 13}}, {{2.71547, 13}, {3.16095, 
   14}, {3.30726, 15}, {3.5329, 16}}, {{3.5329, 16}, {3.63022, 
   17}, {4.34524, 18}, {5.20954, 19}}};
ListLinePlot[data, Frame -> True, PlotTheme -> "Detailed", 
 ImageSize -> 600, InterpolationOrder -> 0]

enter image description here

ListStepPlot[data, Frame -> True, PlotTheme -> "Detailed", 
 ImageSize -> 600]

enter image description here

Here is different data that has a problem

data1={{{0, 1}, {0.139219, 2}, {0.607566, 3}, {1.18343, 4}}, {{1.18343, 
   4}, {1.22964, 5}, {2.01722, 6}, {2.62576, 7}}, {{2.62576, 
   7}, {3.69976, 8}, {3.90317, 9}, {4.49939, 10}}, {{4.49939, 
   10}, {4.83385, 11}, {4.92839, 12}, {5.3667, 13}}, {{5.3667, 
   13}, {5.37191, 14}, {5.75267, 15}, {5.86257, 16}}, {{5.86257, 
   16}, {6.49011, 17}, {6.56514, 18}, {6.73022, 19}}};

"11.1.0 for Microsoft Windows (64-bit) (March 13, 2017)"

$\endgroup$

2 Answers 2

6
$\begingroup$

There is no bug. ListStepPlot gives a different result from ListLinePlot because it is using a different plotting algorithm.

ListStepPlot draws steps (horizontal lines) through the data points and gives the user a choice of three positions for where the data point stands on the horizontal line. It will always extend the first or last step as required to get a full step at that point.

ListLinePlot with InterpolationOrder -> 0 joins the data points with staircase polyline, which is quite a different thing.

To visualize the differences of the plotting methods, we need only give the option Mesh -> Full which makes the data points visible.

ListStepPlot[data, Right,
  Frame -> True, PlotTheme -> "Detailed", Mesh -> Full]

right

Right is the default value for mesh point position.

ListStepPlot[data, Center,
 Frame -> True, PlotTheme -> "Detailed", Mesh -> Full]

center

ListStepPlot[data, Left,
  Frame -> True, PlotTheme -> "Detailed", Mesh -> Full]

left

ListLinePlot[data,
  Frame -> True, PlotTheme -> "Detailed", InterpolationOrder -> 0, Mesh -> Full]

line

It is up to you to chose the one which displays your data more clearly.

$\endgroup$
1
  • $\begingroup$ Thanks for clarification but at least one option of ListLinePlot should produce the same plot as ListLinePlot. I will go with ListLinePlot since that's what I want. $\endgroup$ Jan 19, 2018 at 18:25
3
$\begingroup$

ListStepPlot always produces a step shape. You can decide where you want the resulting "extra bit" of the curve with a second argument.

data = {{{1, 2}, {2, 3}}, {{3, 4}, {4, 5}}};
left = ListStepPlot[data, Left, Mesh -> Full, Frame -> True, 
   PlotTheme -> "Detailed", ImageSize -> 600];
center = ListStepPlot[data, Center, Mesh -> Full, Frame -> True, 
   PlotTheme -> "Detailed", ImageSize -> 600];
right = ListStepPlot[data, Right, Mesh -> Full, Frame -> True, 
   PlotTheme -> "Detailed", ImageSize -> 600];
Row[{left, center, right}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.