Announcement

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

  • graphing a twoway graph with the values on the left and right of the axis of panel data

    Hello All,
    How can I graph a two-way graph with x1 variable (on the right axis) and x2 variable (on the left axis) like the graph below? I am running panel data what is the code to have graph each countries (x1 and x2) variable in one chart but the values on the left and right of the axis?
    Best

    Attached Files

  • #2
    What is in the middle then?

    Start with

    Code:
    webuse grunfeld, clear
    
    twoway line invest time if company <= 3, by(company, row(1)) yaxis(1 2)

    Comment


    • #3
      Thank you Nick Cox.
      Can I run
      twoway (line invest time) (bar kstock time) if company <= 3, by(company, row(1)) yaxis(1 2) When I try the above code, the STATA replied me 'option yaxis() not allowed'
      Since the scaling values of invest and stock are different, can I assign the series axis to the right and left in the y-axis and overlap the scales?
      Best

      Comment


      • #4
        Clearly that's illegal. But I guess that way -- superimposed bar and line chart -- lie misery and frustration.

        Either keep variables separate or scale to common index, e.g. 1945 value = 100.

        Comment


        • #5
          Dear Nick Cox, thank you for the suggestion. But, if two series, for instance, one is fiscal consolidation episodes, when governments contract their fiscal policy if we put one in that period and 0 otherwise. and the other series can be real GDP (a continuous variable), can we graph the two series with the first series to the right and the second series to the left of the y-axis?
          Best

          Comment


          • #6
            The question keeps changing!

            There is a standard kind of plot exemplified by

            Code:
            webuse grunfeld, clear
            
            line invest year if company == 1, yaxis(1) || line mvalue year if company == 1, yaxis(2)

            See
            Code:
            help axis choice options
            but also note that this is often deprecated. Howard Wainer wrote an entire paper against the idea.

            Wainer, H. 1991. Double Y-axis graphs. Chance 4(1): 50-51.

            What you have sounds better approached through a method such as those explained in

            https://www.stata-journal.com/articl...article=gr0067

            https://blog.stata.com/2020/02/13/ad...series-graphs/

            Comment

            Working...
            X