Announcement

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

  • How to adjust the scale on the axes of a graph before outputting in a batch file, if the yscale/xscale option is not available

    If I am not using the twoway plot or some other library that has the yscale() or xscale() option, how do I adjust the scale of a graph before outputting? I am considering this to be a batch file but if that's not possible, then any way to do this interactively would also be appreciated. Thanks

  • #2
    Could you give a small example, please?

    Comment


    • #3
      sure. lets say I am using the xtsemipar library, and for now I just want to play with the example they have in the help window:

      webuse invest2
      generate logi=log(invest)
      generate logm=log(market)
      generate logs=log(stock)
      xtset company time
      xi: xtsemipar logi logm i.time, nonpar(logs)

      Following these commands, a graph comes out. But I have yet to learn a way to change its scale so that it zooms in to a particular region of the graph.

      Comment


      • #4
        This may help on how to extract the data and generate the graph using twoway. Note the FAQ Advice to identify community contributed commands (FAQ #12). xtsemipar is from SSC.
        https://www.statalist.org/forums/for...raph-after-mca

        Comment


        • #5
          In principle xtsemipar (Stata Journal, also) could be revised to accept extra options to control the graph, so you need to lobby the program authors to do that.

          Comment


          • #6
            Here is one way - extracting the data from the graph:

            Code:
            clear*
            webuse invest2,clear
            generate logi=log(invest)
            generate logm=log(market)
            generate logs=log(stock)
            xtset company time
            qui xi: xtsemipar logi logm i.time, nonpar(logs)
            
            tempfile tmp
            serset 0
            serset use,clear
            rename __ linearprediction
            sort logs
            save `tmp'
            serset 1
            serset use ,clear
            ds
            local first: word 1 of `=r(varlist)'
            local second: word 2 of `=r(varlist)'
            rename `first' y
            rename  `second' logs2
            sort logs2
            merge 1:1 _n using `tmp'
            scatter linear logs if logs > 4 /// 
                || line y logs2 if logs2 > 4 /// 
                || ,  name(gr2,replace) legend(off)

            Comment

            Working...
            X