6
$\begingroup$

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:

enter image description here

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

$\endgroup$
5
  • $\begingroup$ 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? $\endgroup$
    – halirutan
    Commented Jul 13, 2018 at 11:58
  • $\begingroup$ my "workaround" would be to remove \space from the spec. of the second family of plot markers $\endgroup$ Commented Jul 13, 2018 at 12:14
  • 2
    $\begingroup$ @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. $\endgroup$
    – kuropan
    Commented Jul 13, 2018 at 12:17
  • 1
    $\begingroup$ @halirutan: I just reported the bug :) $\endgroup$
    – kuropan
    Commented Jul 13, 2018 at 12:18
  • 1
    $\begingroup$ @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. $\endgroup$
    – rcollyer
    Commented Jul 13, 2018 at 20:59

1 Answer 1

3
$\begingroup$

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]

enter image description here

Related Q/A: ListPlot inserts extra PlotMarkers and Mesh at crossing points

Original answer:

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}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Not sure that DataRange is a general solution for any Not@*NumericQ at any place. $\endgroup$
    – rhermans
    Commented Jul 13, 2018 at 11:53
  • $\begingroup$ @rhermans, good point. i just updated with an alternative approach which i hope is more general. $\endgroup$
    – kglr
    Commented Jul 13, 2018 at 12:08
  • $\begingroup$ 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). $\endgroup$
    – kuropan
    Commented Jul 13, 2018 at 12:24
  • $\begingroup$ @kuropan, i had actually copy-pasted the wrong line; corrected now. $\endgroup$
    – kglr
    Commented Jul 13, 2018 at 12:39

Your Answer

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

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