Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graph options

    Dear Stata users,

    I'm trying to combine multiple lqregpred (lqregpred adjs, for(v1) plotvs(v1)) graphs in Stata using -graph combine- command.

    Due to the different width of the labels of individual ticks, the X axes of the graphs start in slightly different positions.

    I am wondering, is there a way to force the X axes to start from the same point in graph region?

    Codes:

    PHP Code:

    gr combine graph1a
    .gph graph2a.gphcols(1iscale(.7273ysize(8graphregion(margin(zero)) 

    Thank you so much.
    Best wishes

  • #2
    not sure I completely understand, but there is an "xcommon" option to the graph combine command; see
    Code:
    help graph combine

    Comment


    • #3
      Thank you so much for your reply. I have tried that option, but could not get good graphs.

      Comment


      • #4
        In my experience there is no easy way to get graph combine to do what you want. Our looks like you would have to use the -generate- option of lqregpreds to generate the data underlying each plot, and then create the graph by hand, using by() to create multiple panels. There would likely be some data reshaping along the way, though I'm not sure as I'm not familiar with that command.

        The other approach would be to add some transparent tick labels to all the graphs that are long enough to force a common label width...

        Comment


        • #5
          To illustrate, you could do something like this:
          Code:
          clear
          // run model 1
          sysuse auto
          lqreg rep78 mpg
          lqregpred adjs, for(mpg) plotvs(mpg)
          keep mpg rep78 adjs50
          gen model = 1
          save model1, replace
          
          // run model 2
          sysuse auto
          
          
          lqreg rep78 mpg price weight
          lqregpred adjs, for(mpg) plotvs(mpg)
          keep mpg rep78 adjs50
          gen model = 2
          
          // combine datasets
          append using model1
          sort mpg
          label define model 1 "Simple model" 2 "Model with congrols"
          la val model model
          
          // make graph
          twoway line adjs mpg || scatter rep78 mpg , by(model , legend(off))

          Comment


          • #6
            Nice! Thank you so much your help.

            Comment

            Working...
            X