8
$\begingroup$

I don't understand the following behaviour I'm seeing with ListPlot and Labeled. It seems like a bug to me, but I'm wondering if someone else can explain it.

The following code produces an "empty" graph:

ListPlot[{{Labeled[{1, 0}, 1], Labeled[{-1, 0}, 1]}, 
          {Labeled[{0, -1}, 1], Labeled[{0, 1}, 1]}}]

empty plot

I say "empty" as it's not quite empty: it shows two of the labels, but none of the points. The axes are also correctly scaled to fit the data, but the data points are not visible.

If one adds a duplicate point, then the four data points are visible as I would have originally expected:

ListPlot[{{Labeled[{1, 0}, 1], Labeled[{-1, 0}, 1], Labeled[{-1, 0}, 1]}, 
          {Labeled[{0, -1}, 1], Labeled[{0, 1}, 1]}}],

Alternatively, if one of the points is removed from one of the lists, then the result is as expected as well:

ListPlot[{{Labeled[{1, 0}, 1]},
          {Labeled[{0, -1}, 1], Labeled[{0, 1}, 1]}}],

Moreover, if the lists of data contain only a single point each, then it works as I expect too:

ListPlot[{{Labeled[{1, 0}, 1]}, { Labeled[{0, 1}, 1]}}],

I can only seem to get the invalid result when I have two data points per list. Note that I want the data as two separate lists so that I can apply different directives to them to style the two lists of points separately.

Can anyone explain to me why the original example doesn't display four data points?


It's worth adding that, if the Labeled wrappers are removed, then the four points are also plotted as expected, though obviously without the required labels.

$\endgroup$
  • 2
    $\begingroup$ This is a bug, it worked in version 10.3 $\endgroup$ – Jason B. May 22 '18 at 20:58
  • $\begingroup$ I avoided the `bug' tag originally as the tag description said not to apply it. I agree it's the appropriate tag though, thanks. $\endgroup$ – Se314en May 22 '18 at 20:59
  • $\begingroup$ @JasonB. did you just check that? I don't have access to an older version to check myself, so can you confirm it as working in 10.3? $\endgroup$ – Se314en May 22 '18 at 21:00
  • 1
    $\begingroup$ Another workaround is to add an invalid point (like Indeterminate) to one of the datasets, e.g., ListPlot[{{Labeled[{1, 0}, 1], Labeled[{-1, 0}, 1], Indeterminate}, {Labeled[{0, -1}, 1], Labeled[{0, 1}, 1]}}] $\endgroup$ – Carl Woll May 22 '18 at 21:36
  • 3
    $\begingroup$ same issue with other wrappers,.e.g. Callout and Style $\endgroup$ – kglr May 23 '18 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.