# Bug in ListPlot: Duplicate markers (one list containing Infinity)

simple plot of two lists, of which one contains infinity (markers are slightly shifted):

ListPlot[
{{3, 4, 5},{1, Infinity, 2}},
PlotMarkers -> {{"\[FilledDiamond]", 13}, {"   \[FilledDiamond]", 13}},
PlotStyle -> {Red, Black}
]


What I get is this:

Note the duplicate red points for each black point!

This definitely doesn't seem right, can someone confirm that?

My current workaround is to just replace all Infinitys with a low number and then adjust the PlotRange.

Update: I contacted the Mathematica Technical Support Team, which confirmed the bug and said they'd work on that. In the meantime, there's plenty of workarounds, so I marked the question as solved.

Cheers

• For others seeing this question: Usually, we have the rule to only apply the [bugs] tag to confirmed bugs, but I believe the situation is pretty clear and the example is simple enough to assume that what happens here is not OK. @kuropan, Would you consider reporting this to Wolfram, so that they are aware of this issue? – halirutan Jul 13 '18 at 11:58
• my "workaround" would be to remove \space from the spec. of the second family of plot markers – Gregory Rut Jul 13 '18 at 12:14
• @GregoryRut: I stumbled on this problem when plotting several lines of data on top of each other and was shifting the markers slightly to deal with markers that end up on top of each others. So this isn't a workaround for me unfortunately. – kuropan Jul 13 '18 at 12:17
• @halirutan: I just reported the bug :) – kuropan Jul 13 '18 at 12:18
• @kuropan yep, saw it, and it is a duplicate of (or at least heavily related to) other issues around PlotMarkers. They have been fixed, and will be available in a future release. – rcollyer Jul 13 '18 at 20:59

Update: a simpler work-around: add the option Mesh -> Full

data = {{3, 4, 5}, {1, anything, Infinity, 2}} ;
ListPlot[data, PlotMarkers -> {{"◆", 13}, {"   ◆", 13}}, PlotStyle -> {Red, Black},
Mesh -> Full]


The issue is not limited to data sets containing ∞, we get the same issue if ∞ is replaced with any non-numeric element.

A work-around: (1) transform input data to have explicit horizontal coordinates and (1) delete pairs with non-numeric elements:

data = {{3, 4, 5}, {1, anything, Infinity, 2}} ;
ListPlot[DeleteCases[Transpose[{Range[Length @ #], #}] & /@ data,
{_, Except[_?NumericQ]}, {2}],
PlotMarkers -> {{"◆", 13}, {"   ◆", 13}},
PlotStyle -> {Red, Black}]


• Not sure that DataRange is a general solution for any Not@*NumericQ at any place. – rhermans Jul 13 '18 at 11:53
• @rhermans, good point. i just updated with an alternative approach which i hope is more general. – kglr Jul 13 '18 at 12:08
• Nice workarounds! Just noticed that you deleted the space in front of the second [\FilledDiamond] though, so you would not actually see from running the code, if your workarounds resolved the issue (as the markers would lay on top of each other). – kuropan Jul 13 '18 at 12:24
• @kuropan, i had actually copy-pasted the wrong line; corrected now. – kglr Jul 13 '18 at 12:39