Below is a plot I made in MATLAB.
I need to recreate the above plot in Mathematica. This is what I'm able to achieve on Mathematica 12.2 (the slight formatting differences compared to the MATLAB plot are intentional):
As we can see, the plot in Mathematica has a non-zero "fence width" on top of each plot marker whereas the plot made in MATLAB does not. Is there any way to achieve error bars as shown in the MATLAB plot using Mathematica?
If we assume the x-coordinates are stored in xData
, the y-coordinates in yData
, and the tops of the error bars in yMaxData
(all vectors of the same length), the code I use in Mathematica to generate this plot (ignoring all the formatting) is:
linePlotData1 = Table[{xData[[ii, 1]], Around[yData[[ii, jj]], {0, yMaxData[[ii, jj]]}]}, {jj, 1, numCols}, {ii, 1, numRows}];
where numCols
is 2 in this case and numRows
is 10 (the length of the data vectors).
To generate the plot, I use ListPlot[linePlotData1]
with ScalingFunctions
set to {"Log", "Log"}
and various other formatting-related commands including IntervalMarkersStyle
to format the thickness and color of the error bars. However, I wasn't able to find any documentation regarding whether or not I can format the positive and negative directions of the error bars differently.
Is there a way to do this, preferably without having to use any external packages?
For example, can I set IntervalMarkers
to "Bars" for the negative and "Fences" for the positive directions, respectively? The documentation doesn't seem to have any information on whether or not doing so is possible. I tried something like IntervalMarkers -> {{"Bars","Fences"},{"Bars","Fences"}}
(repeated twice for each of the two data "columns"), but this threw an error.
Thanks!
ListPlot[data]/. Line[pat:{{_List,_Offset}..}]:>Line[pat[[;;2]]]
give what you need? $\endgroup$