I would like to plot data of my phd thesis and use the ListPlot function together with Around[] to create Errorbars. I've tried a TwoAxisListPlot function(function in the appendix attatched), which combines several graphics, but was not able to match the colors of the errorbars and datasets shown. I reduced to a MWE and the same problem is still persistent. Is this a bug in ListPlot or is it me not unterstanding? (I am using Win10 64bit, Mathematica

I've got a dataset given by testdata in this case and specify a set of colors or even move specific with graphics directives


testdata = Table[Around[i^2, i], {i, 10}]
colors = ColorData[97,"ColorList"];
direc = Directive[#]&/@colors;

specifyAll = ListPlot[testdata, PlotStyle->colors, IntervalMarkersStyle->colors];
specifyAutomatic = ListPlot[testdata, PlotStyle->colors, IntervalMarkersStyle->Automatic];
specifyStyle= ListPlot[testdata, PlotStyle->colors];
specifyNothing = ListPlot[testdata];

GraphicsGrid[{{specifyAll, specifyAutomatic, specifyStyle, specifyNothing}}, ImageSize -> {1400, 350}]

Output looks like this: wrong coloring as desribed

In the end I end up either with completely wrong colors (not the first in the list, but the last one) or not matching colors. I was only able to match colors for for markers and errorbars only and only if no colors or styles are specified.

Due to the desire to combine multiple graphs into a TwoAxisPlot I need to specify different colors and can't just leave it as default, but I am not able to get this to work.

Thanks in advance

Appendix: this is the TwoAxisPlot based on other posts from the forum, slightly modified. But all options are passed correctly and the MWE shows the same error. So this problem does not stems not from this function. Everything was tested on fresh kernels as well as a restartet PC.

TwoAxisListPlot[{f_List, g_List}, ranges_, opts: OptionsPattern[]] := Module[{localOptions, localStyle, localFrameStyle, fgraph, ggraph, localRanges, frange, grange, fticks, gticks},
    localStyle = If[FreeQ[{opts},PlotStyle],ColorData[97,"ColorList"],FilterRules[{opts},PlotStyle][[1,2]]];
    localOptions = Join[FilterRules[{opts},FilterRules[Options[ListPlot],Except[{FrameStyle, FrameTicks, PlotRange, Background, Frame, Axes}]]],{Frame->True, Axes->True}];
    localFrameStyle = Select[((FrameStyle/.{opts})/.Options@Plot),!(Head@#===List)&]; (* kick out any user specified coloring *)
    localFrameStyle = Map[Directive@@Flatten[Join[{localFrameStyle},{#}]]&, {localStyle[[1;;2]], {Automatic, Automatic}}, {2}]; (*merge it into automatic detected coloring *)
    localRanges = If[Length@ranges == 3, {ranges[[{1,2}]],ranges[[{1,3}]]}, ranges];
    {fgraph, ggraph} = MapIndexed[ListPlot[#, PlotRange->localRanges[[First@#2]],PlotStyle->localStyle[[First@#2]], Evaluate@(Sequence@@localOptions), Axes -> True] &, {f, g}];
    {frange, grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[2]] & /@ {fgraph, ggraph}; 
    fticks = N@FindDivisions[frange, 5];
    gticks = Quiet@Transpose@{fticks, ToString[NumberForm[#, 2], StandardForm] & /@ Chop[Rescale[fticks, frange, grange],10^-6]};
        fgraph, ggraph /. Graphics[graph_, s___] :> Graphics[GeometricTransformation[graph, RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s], Axes -> False, Frame -> True, 
        FrameStyle -> localFrameStyle, FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}},Evaluate@Sequence@@localOptions
  • $\begingroup$ Can you confirm that ListPlot[testdata, PlotStyle -> ColorData[97, "ColorList"]] gives you the wrong output. It is correct for me. $\endgroup$
    – SquareOne
    Apr 8, 2021 at 13:10
  • $\begingroup$ @SquareOne it does not, for me it's green dots with blue error bars. Which version you are on? I think this issue is connected with Around, which was introduced in v12.0 and might be subject to change as it is stated in the documentation, that it is an experimental feature. $\endgroup$
    – Max Hacki
    Apr 9, 2021 at 17:16

1 Answer 1


Specify the index for the color desired.


testdata = Table[Around[i^2, i], {i, 10}];
colors = ColorData[97, "ColorList"];
direc = Directive[#] & /@ colors;

index = RandomInteger[{1, Length@colors}]

(* 11 *)

specifyAll = 
  ListPlot[testdata, PlotStyle -> colors[[index]], 
   IntervalMarkersStyle -> colors[[index]], PlotLabel -> "specifyAll"];
specifyAutomatic = 
  ListPlot[testdata, PlotStyle -> colors[[index]], 
   IntervalMarkersStyle -> Automatic, PlotLabel -> "specifyAutomatic"];
specifyStyle = 
  ListPlot[testdata, PlotStyle -> colors[[index]], 
   PlotLabel -> "specifyStyle"];
specifyNothing = ListPlot[testdata, PlotLabel -> "specifyNothing"];

GraphicsGrid[{{specifyAll, specifyAutomatic}, {specifyStyle, 
   specifyNothing}}, ImageSize -> {600, 350}]

enter image description here

  • $\begingroup$ thanks Bob for your time and you trying to adress my issue! unfortunatelly I haven't made my point clear enough .... I want the whole selection of points to have the same color and matching errorbars, which is not the case if one just specifies the list of colors. I know, that given a single list this should lead to a single color plot, even though one specifies more colors ... but they are not used in the correct order :( $\endgroup$
    – Max Hacki
    Apr 6, 2021 at 15:37
  • $\begingroup$ Thanks Bob, that resolves the issue, but I still think this is not intended, right? Further testing showed similar things for Plot aswell. As soon as a list of colors is given as a plotstyle and a single dataset or funciton is plotted, the last one is used. As soon as two functions or lists are plotted and a larger list of styles is given this list is used from the start. $\endgroup$
    – Max Hacki
    Apr 6, 2021 at 16:46
  • $\begingroup$ As long as the behavior is consistent from one use to the next, I would assume that however it works is "as intended"; unless it changes from one version to the next (and has not been identified as an intended change). $\endgroup$
    – Bob Hanlon
    Apr 6, 2021 at 17:16

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.