2
$\begingroup$

I have a plot with y-error bars and would like to increase the tick size of my error bars. This is the code for a simple example plot:

Data = Table[{X, Around[X, 0.5]}, {X, 1, 10}];
ListPlot[Data,
 ImageSize -> Large,
 PlotMarkers -> {"+", 30}]

With this, the "+" that marks the point is much wider than the tick of the corresponding error bar and I want this to be the other way around.

I could only find a solution for ErrorListPlot, but none using the ListPlot and Around functions.

$\endgroup$
3
$\begingroup$

You can use the options IntervalMarkers and IntervalMarkersStyle as follows:

ListPlot[Data, ImageSize -> Large, PlotMarkers -> {"+", 30}, 
 IntervalMarkers -> "Fences", 
 IntervalMarkersStyle -> <|"FenceWidth" -> .20, 
   "FenceStyle" -> Directive[Red, Thick], 
   "WhiskerStyle" -> 
       Directive[CapForm["Butt"], Opacity[.5], AbsoluteThickness[20],  Green]|>]

enter image description here

Update: To get plot markers aligned with the data coordinates we need to use graphics-based markers (see this q/a about alignment issues with font-based markers).

Define

plus = Graphics @ First[First[
   ImportString[ExportString[Style["+", FontSize -> 24], "PDF"], 
     "PDF", "TextMode" -> "Outlines"]]]

and use it as

ListPlot[Data, ImageSize -> Large, 
 PlotMarkers -> {plus, 15}, 
 IntervalMarkers -> "Fences", 
 IntervalMarkersStyle -> <|"FenceWidth" -> .20, 
   "FenceStyle" -> Directive[Red, CapForm["Butt"], Thick], 
   "WhiskerStyle" -> 
     Directive[CapForm["Butt"], Opacity[.5], AbsoluteThickness[25], Green]|>]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you for this option! The picture you posted is also a great example of an unrelated question I've had for a while: The distance from the lower end of the "+" to the lower error bar is significantly smaller than the distance from the upper end of the "+" to the upper error bar. Since the error is symmetric I would expect the distance to be the same, but I've seen similar things in Mathematica multiple times. Do you know why this happens? $\endgroup$ – camileri Jan 7 at 15:26
  • 1
    $\begingroup$ @camileri, thank you for the accept. I added a fix and a link re the marker alignment issue. $\endgroup$ – kglr Jan 7 at 16:34
  • $\begingroup$ Wow, this exposes a much larger issue I've had: I have manually set PlotMarkers on many occasions and since 'PlotMakers -> {[FilledCircle], 20}' did not change the size of the plot marker, I often used PlotMakers -> {"\[FilledCircle]", 20} as this allowed me to change the size. I should obviously not have done this, because of the resulting alignment issue. Can you also tell me how I can properly change the size manually? I cannot stress enough how helpful your comments were as it would have taken me forever to figure this out without your help. Thank you so much! $\endgroup$ – camileri Jan 7 at 18:45
  • 1
    $\begingroup$ @camileri, you can use PlotMarkers -> {Graphics[{Disk[]}], .05} instead of PlotMakers -> {"\[FilledCircle]", 20}. $\endgroup$ – kglr Jan 7 at 19:08

Your Answer

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

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