How to give a small horizontal space between each point in ListPlot variants?

I'm trying to create a graph with error bars by ErrorListPlot which is a function in ErrorBarPlots context.

The data I want to show can be downloaded from my dropbox: https://www.dropbox.com/s/95sk278drhfl2hj/sampleData.dat?dl=0 You might face a problem when Import the above data that the elements at level three are not recognized correctly. Sorry but I don't know how to resolve it.

The structure of the data is: Dimension[data]={7, 37, 2}, data[[1,2]]={20., 2.76131}.

Anyway, straightforwardly, the following command gives me a plot as follows:

                  PlotRange -> {-80, 80},
                  GridLines -> Automatic,
                  PlotLegends -> SwatchLegend[Automatic, LegendMarkerSize -> 15],
                  ImageSize -> Large]

the output

The resulting graph is good other than that, many points and error bars are overlaid with each other and we hardly can see the detail for points behind.

My idea to resolve this problem is to give a small horizontal space for each data point so that they can be seen separately. I, however, don't know how to realize it.

Does any of you guys know how to realize it? Or some other clever way to make it readable is also welcome.

I use Mathematica ver.

Thank you in advance.


At first, the permission of the link to my dropbox was inappropriate and nobody can download it. Now I change it and anyone can download it. Sorry for the inconvenience.

  • $\begingroup$ can you post Dimension[data] and data[[1,2]] for data in your ErrorListPlot[data,...]? $\endgroup$
    – kglr
    Feb 13, 2022 at 20:07
  • $\begingroup$ Try saving your data as .csv rather than .dat $\endgroup$
    – Bob Hanlon
    Feb 13, 2022 at 20:35
  • 1
    $\begingroup$ Please see medium.com/nightingale/… and related topics. Your graph (even with horizontal spacing) is currently close to unintelligible. $\endgroup$
    – JimB
    Feb 13, 2022 at 21:42
  • $\begingroup$ @kglr Dimension[data]={7, 37, 2}, data[[1,2]]={20., 2.76131} $\endgroup$ Feb 14, 2022 at 5:09
  • $\begingroup$ @BobHanlon .csv didn't resolve it. I don't know how to export data as preserving the structure with more than three levels. $\endgroup$ Feb 14, 2022 at 5:51

1 Answer 1


First, based on the picture in OP, a simple data set that reproduces the issue in OP:

epdata = Table[Table[{RandomReal[1], RandomReal[0.5]}, {i, 10}], 5];


elp = ErrorListPlot[epdata, 
  PlotRange -> {{0, 1 + Length@epdata[[1]]}, {-1/2, 3/2}}, 
  PlotLegends -> SwatchLegend[Automatic],
  ImageSize -> Large, 
  GridLines -> {1/2 + Range[0, 1 + Length@epdata[[1]]], None}]

enter image description here

Define a helper function that produces a list of x-coordinate displacements so that n points with shared x-coordinate x0 are equally spaced in the interval from x0 - width/2 to x0 + width / 2:

xDisplacements[width_: 1/3] := Subdivide[-width/2, width/2, Length[#] - 1] &

translations = Thread[{xDisplacements[][epdata], 0}];

Post-process elp to translate points and lines using translations:

ReplaceAll[prims : {_Point, ___} :> 
   Translate[prims, Last[translations = RotateLeft[translations]]]] @ elp 

enter image description here

Use translations = Thread[{xDisplacements[1/4][epdata], 0}]; above to get

enter image description here


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.