13
$\begingroup$

Bug introduced in 7.0 or earlier and persisting through 13.2.0 or later


My code:

data = {MapIndexed[{First[#2], #1} &, 
    Accumulate[RandomInteger[{-1, 1}, {54}]]], 
   MapIndexed[{First[#2], #1} &, 
    Accumulate[RandomInteger[{-1, 1}, {34}]]]};

ListPlot[data,
 Axes -> False,
 AspectRatio -> 0.75,
 Frame -> True,
 InterpolationOrder -> {0, 0},
 ImageSize -> {400, 300},
 ImageMargins -> 0,
 Joined -> True,
 PlotMarkers -> {{"\[FilledCircle]", 11}, {"", 11}}
 ]

On OS X 10.6.8 V8.0.4 I get this output:

enter image description here

You will note that the filled circle plot markers have been "distributed" across both sets of data. However if I change the InterpolationOrder setting to say:

InterpolationOrder -> {0, None}

...then no markers appear for the second set of data (due to the markers being an empty string).

enter image description here

Could someone please advise me if the cause of this behaviour is due to me setting these options incorrectly? Any ideas?

$\endgroup$
5
  • $\begingroup$ Yes, I see this too. To see if it's related to the shape of the lists, I tried the following, but got the same wrong plot with InterpolationOrder -> {0, 0} (and it's also wrong with ListLinePlot): data = {Accumulate[RandomInteger[{-1, 1}, {54}]], Accumulate[RandomInteger[{-1, 1}, {34}]]}; $\endgroup$
    – Jens
    Commented Jun 22, 2012 at 4:35
  • $\begingroup$ Interesting. If I try InterpolationOrder -> 0, both plots are marked, while with InterpolationOrder -> 1, only one set is marked. Hmm... $\endgroup$ Commented Jun 22, 2012 at 4:36
  • $\begingroup$ Further intriguing behavior: ListPlot[data, Axes -> False, AspectRatio -> 0.75, Frame -> True, InterpolationOrder -> 0, ImageMargins -> 0, Joined -> True, PlotMarkers -> {{"\[FilledCircle]", 11}, {"\[FilledSmallSquare]", 11}}]. (Setting InterpolationOrder -> 1 gives the expected result, however.) $\endgroup$ Commented Jun 22, 2012 at 4:40
  • $\begingroup$ @ilian, I presume somebody there is looking at this now? This has lasted quite a while… $\endgroup$ Commented Aug 24, 2015 at 15:47
  • 1
    $\begingroup$ @J. M. I've notified the developers/QA listed on the internal bug report. $\endgroup$
    – ilian
    Commented Aug 24, 2015 at 16:01

1 Answer 1

13
$\begingroup$

According to the doc, the second result is correct, since $i$-th specification in PlotMakers should be used for $i$-th dataset. There seems to be a bug regarding how InterpolationOrder->0 is processing PlotMarkers.

When InterpolationOrder->0, it inserts PlotMarkers at the both end of each interval. Not so for all other cases (it inserts markers on the data point). While doing so, it seems that it always picks up the first plot marker for the end interval point, instead of the correct one (n-th plot maker for n-th data set).

It is easy to confirm. Define multi-data:

SeedRandom[2]; data = {MapIndexed[{First[#2], #1} &, 
   Accumulate[RandomInteger[{0, 1}, {10}]]], 
  MapIndexed[{First[#2], #1} &, 
   Accumulate[RandomInteger[{-1, 1}, {15}]]],
  MapIndexed[{First[#2], #1} &, 
   Accumulate[RandomInteger[{-1, 0}, {15}]]]};

Then run the plot with interpolation order 0:

ListPlot[data, Axes -> False, AspectRatio -> 0.75, Frame -> True, 
 InterpolationOrder -> {0, 0, 0}, ImageSize -> {400, 300}, 
 ImageMargins -> 0, Joined -> True, 
 PlotMarkers -> {{"\[FilledCircle]", 8}, {"\[FilledSquare]", 
    10}, {"\[FilledDiamond]", 10}}]

The result is:

enter image description here

When it should have looked like this:

enter image description here

(which is generated by:

Show[MapThread[
  ListPlot[#1, Axes -> False, AspectRatio -> 0.75, Frame -> True, 
    InterpolationOrder -> 0, ImageSize -> {400, 300}, 
    ImageMargins -> 0, Joined -> True, PlotMarkers -> #2, 
    PlotStyle -> #3] &, {data, {{"\[FilledCircle]", 
     8}, {"\[FilledSquare]", 10}, {"\[FilledDiamond]", 10}}, 
   ColorData[1, "ColorList"][[1 ;; 3]]}], PlotRange -> {{0, 15}, All}]

)

$\endgroup$
5
  • $\begingroup$ Will you log it as a bug? $\endgroup$ Commented Jun 22, 2012 at 4:43
  • 10
    $\begingroup$ Already did, Mike. $\endgroup$ Commented Jun 22, 2012 at 4:46
  • $\begingroup$ Three years later and the bug remains. Would someone agitate the water a bit, please? $\endgroup$
    – Mr.Wizard
    Commented Jun 18, 2015 at 8:23
  • 3
    $\begingroup$ @Mr. Wizard, considering that Yu-Sung isn't "there" anymore, we should prolly be bugging somebody else… $\endgroup$ Commented Jun 18, 2015 at 9:01
  • $\begingroup$ @J. M. Sorry, my memory is terrible. $\endgroup$
    – Mr.Wizard
    Commented Jun 18, 2015 at 9:04

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