Announcement

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

  • Two-way scatter, problem with y axis scale

    Hi!
    Iam having problem fixing the y axis scale. see the picture below. I want the plots to be spread out so that its 5.85 at the bottom and 6.05 at the top of the y axis. How can i do this?

    Code:
    twoway (line lnw yob) (scatter lnw yob if q4 == 1, mlabel(quarter4) mlabposition(12)) (scatter lnw yob if q3 == 1, mlabel(quarter3) mlabposition(12) msym(Oh)) (scatter lnw yob if q2 == 1, mlabel(quarter2) msym(Oh) mlabposition(12)) (scatter lnw yob if q1 == 1, mlabel(quarter1) msym(Oh) mlabposition(12)), name(figure3org) scheme(s2mono)title("Original sample") legend(order (3 "Quarter 1" 2 "Quarter 4")) ysc(r(5.85 6.05))
    Kind regards,
    Andre
    Attached Files

  • #2
    Take out ysc(r(5.85 6.05))


    EDIT: the minmax option is also possible. You'll only have two values at the end, but it'll literally constrain the axis to be at the very minimum value to the maximum one

    Comment


    • #3
      Thank you your answer! I dont think i managed to explain my problem.
      What iam trying to achieve is to get these 2 graphs from different datasets to use the same scale on the Y axis.
      Iam editing them in different datasets and then import the .gph to one of the sets and then graph combine. Is there a way to get the "original sample" on the same scale as the graph on the left?

      Ifigure 3 reduced.gph
      Click image for larger version

Name:	figure 3 reduced.jpg
Views:	1
Size:	37.1 KB
ID:	1660544

      Attached Files

      Comment


      • #4
        Originally posted by Andre Westman View Post
        I am editing them in different datasets and then import the .gph to one of the sets and then graph combine.
        Use the -by()- option instead. See https://journals.sagepub.com/doi/10....36867X20976341

        Comment


        • #5
          Did you try the option ycommon when combining the graphs?
          otherwise you can also add xlabel(5.85(0.05)6.05) to your second graph

          Comment


          • #6
            To get the same scale, at most you may need to do something like


            Code:
            summarize ....
            local max = r(max) 
            local min = r(min) 
            
            summarize ... 
            local max = max(`max', r(max)) 
            local min = min(`min', r(min))
            where the dots ... are not literal syntax but need to be filled in with the data specification for each graph. Then call up ysc() with the minimum and maximum so decided.

            If you know that the limits of one graph apply to the other automatically -- e.g. if the second graph is for a subset of the data of the first graph -- then it's simpler.

            It's possible that on other grounds you want to specify certain axis labels to be shown.

            Comment


            • #7
              Originally posted by Nick Cox View Post
              To get the same scale, at most you may need to do something like


              Code:
              summarize ....
              local max = r(max)
              local min = r(min)
              
              summarize ...
              local max = max(`max', r(max))
              local min = min(`min', r(min))
              where the dots ... are not literal syntax but need to be filled in with the data specification for each graph. Then call up ysc() with the minimum and maximum so decided.

              If you know that the limits of one graph apply to the other automatically -- e.g. if the second graph is for a subset of the data of the first graph -- then it's simpler.

              It's possible that on other grounds you want to specify certain axis labels to be shown.
              Thanks alot Nick!

              Comment

              Working...
              X