How to draw a plot with mean and CI? I want to draw a plot in Matlab or Stata. I have a mean and CI for some distribution. there should be a line with the upper end of the line representing the upper CI and the lower end the lower CI and the middle, the average.
I am not sure how to do it or how to search for it. Can anyone kindly help me out ? Thanks.
NB:  is there a way to connect these CI ? (with straight lines ? 3 straight lines)
 A: I can speak for Stata.
First, install the user-written program -ciplot- by typing
ssc install ciplot

You can obtain detailed help for this command by typing
help ciplot

Load a sample dataset
webuse citytemp

then, to show an example, type the following command.
ciplot heatdd, by(division) hor


or, to plot vertically, just drop the "hor" at the end of the command

ciplot heatdd, by(division)

A: Ahsan:
You've asked twice about connecting these CIs in response to the examples above.  Building on lejohn's example, here's some ways to show connected CI lines:
**********begin
clear 
input str2 varname mean upper lower
x1 30 25  35
x2 50 20  80
x3 60 50  70
x4 60 55  65
x5 65 55  75
end

encode varname, gen(varname1)


*CI line properties
loc prop " msize(large) msymbol(d) lwidth(thick)  "

tw (connected mean varname1, xlabel(, valuelabel) ) ///
    (connected upper varname1, `prop' ) ///
    (connected lower varname1, `prop' )


**Or use lfitci
tw (lfitci mean varname1, xlabel(, valuelabel)) 

**********end

A: Next to this correct answer, I would like to add an alternative approach for Stata. This approach can be used if a table containing the means and the limits of the intervals is already available. This approach may also be applied if you prefer a first principles solution to a user-written program.
In the example below, you have a table with means and confidence intervals for 5 variables called x1, x2, x3, x4 and x5. Such a table can be generated by Stata or another software. 
clear 
input str2 varname mean upper lower
x1 30 25  35
x2 50 20  80
x3 60 50  70
x4 60 55  65
x5 65 55  75
end

encode varname, gen(varname1)
scatter mean varname1, xlabel(, valuelabel) || rcap upper lower varname1

If for any reasons whatsoever you want to connect the points by lines, try the following:
scatter mean varname1, xlabel(, valuelabel) \\\
        || rcap upper lower varname1 \\\
        || line upper mean lower varname1

The triple backslash is used to split up the line. Note that the triple backslash cannot be used Stata's command line. 
A: If your confidence intervals are symmetric, MATLAB provides the errorbar(x,ymean,error) function.
