2
$\begingroup$

I want to plot something like the graph in the figure.

grapgh

I have some points (data) and each of them is associated to two different confidence intervals, at 90% (red) and 95% (blue). These intervals can be asymmetric, as you see in the picture.

I tried to use ErrorListPlot but I don't manage to plot only the x-errors and the results is a mess.

$\endgroup$

closed as off-topic by Feyre, MarcoB, Edmund, Yves Klett, JungHwan Min Nov 29 '16 at 4:03

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – MarcoB, Yves Klett, JungHwan Min
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Feyre, Edmund
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Please add data to work with and show what you tried so far. $\endgroup$ – Yves Klett Nov 27 '16 at 18:27
6
$\begingroup$
Needs["ErrorBarPlots`"]

ErrorBar accepts two arguments:

plot0 = ErrorListPlot[{{{1, 1}, ErrorBar[0.3, 0]}}]

enter image description here

which each can be in form of a List to indicate assymetric confidence intervals:

plot1 = ErrorListPlot[{{{1, 1}, ErrorBar[{-0.5, 0.1}, 0]}}]

enter image description here

plot2 = ErrorListPlot[{{{1, 1}, ErrorBar[{-0.7, 0.3}, 0]}}, PlotStyle -> Red]

enter image description here

You can then just Show two plots together (mind the order):

Show[plot2, plot1]

enter image description here

or with a more appealing look by introducing an offset (credit: Bob Hanlon):

Show[plot1 /. {x_?NumericQ, y_?NumericQ} -> {x, y + 0.03}, 
     plot2 /. {x_?NumericQ, y_?NumericQ} -> {x, y - 0.03}]

enter image description here


As far as I know, ErrorListPlot isn't very flexible when it comes to styling the points and bars separately (see here and here for custom implementations). I'd combine it simply with a ListPlot:

plot1 = ErrorListPlot[{{{1, 1}, ErrorBar[{-0.5, 0.1}, 0]}}, 
  PlotStyle -> PointSize[0]]
plot2 = ErrorListPlot[{{{1, 1}, ErrorBar[{-0.7, 0.3}, 0]}}, 
  PlotStyle -> {Red, PointSize[0]}]

Show[plot2, plot1, 
 ListPlot[{{1, 1}}, PlotStyle -> {Black, PointSize[Large]}]]

enter image description here

$\endgroup$

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