Ahsan
Ahsan

Reputation: 2982

How to overlay multiple plots on the same graph in Stata?

I am using the following code for drawing a plot on a graph in Stata. I want to draw multiple plots on the same graph. Is that possible? Can anyone kindly tell me what to do?

What I want to do is to have multiple plots of the following types in the same graph.

Further clarification: There will be multiple means and CIs for each value of X, i.e. one mean and CI for each simulation model. All the means and CIs for one simulation model will be connected together.

    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 || line upper mean lower varname1

Upvotes: 2

Views: 19313

Answers (1)

Ahsan
Ahsan

Reputation: 2982

As @whuber kindly mentioned, we need to use || to draw more things. I used the following code to draw more than one plot of the type I need on the same graph. Thanks.

    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)

    input str4 varname4 mean4 upper4 lower4
    x1 40 35  45
    x2 60 30  90
    x3 70 60  80
    x4 70 65  75
    x5 75 65  85

    scatter mean varname1, xlabel(, valuelabel) || rcap upper lower varname1 || line upper mean lower varname1 ||scatter mean4 varname1, xlabel(, valuelabel)  || rcap upper4 lower4 varname1  ||  line upper4 mean4 lower4 varname1

Upvotes: 3

Related Questions