2
$\begingroup$

Consider the following simple example of using ListPlot with Labeled data:

ListPlot[
 RandomReal[{-1, 1}, {2, 6}] // Map[Labeled[#, "Test"] &]
]

enter image description here

So far, so good. Now, I want to do the same with an ErrorListPlot, and thus write

Needs["ErrorBarPlots`"];
ErrorListPlot[
 RandomReal[{-1, 1}, {2, 6}] // Map[({#, 0.2} &), #, {2}] & // 
  Map[Labeled[#, "Test"] &]
 ]

Unfortunately, this just gives me a blank plot.

Why does this happen? Is there a way to use Labeled (or similar functionality) to work with an ErrorListPlot (possibly without having to reimplement it with Graphics primitives)? Note that I'm aware that I can use PlotLegends, but that's not what I am looking for (unless it can be used to produce the same kind of output as Labeled).

$\endgroup$
2
  • $\begingroup$ ErrorListPlot is obsolete, unmaintained, and likely hasn't been updated to support wrappers.. Why not use Around with ListPlot/ListLinePlot? $\endgroup$
    – ktm
    Commented Aug 27, 2019 at 14:40
  • $\begingroup$ @user6014 I didn't know it was considered obsolete. Never heard of Around. That seems to be the ideal solution, but I don't have v12 so I guess I can't use it right now $\endgroup$
    – glS
    Commented Aug 27, 2019 at 14:43

1 Answer 1

2
$\begingroup$
SeedRandom[1]
data = RandomReal[{-1, 1}, {2, 6}] // Map[({#, 0.2} &), #, {2}]&;

You can use PlotLabels with ErrorListPlot:

Needs["ErrorBarPlots`"];


ErrorListPlot[data,
   Joined -> True, PlotLabels -> {"Test", "Test"}, PlotTheme -> "Detailed"]

enter image description here

As commented by user6014, in versions 12+, you can use Around :

data2 = Apply[Around, data, {-2}];

Wrapping each dataset with Callout ListPlot produces the desired look:

ListPlot[Map[Callout[#, "Test"] &] @ data2, 
  Joined -> True, PlotTheme -> "Detailed"]

enter image description here

$\endgroup$

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.