Announcement

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

  • How to modify y-axis range?

    Hello guys, im new here. And also im new with stata. Im having minor problem which is i do not know how to adjust the range of y-axis.
    im doing kaplan-meier graph and for this graph i want to cut the range between 0 to 0.5. i have upload a picture to make it more clear..
    please help me fix this problem. thank you

  • #2
    just to be clear, i want 0.75 to be the starting point replacing 0 in y-axis.

    Comment


    • #3
      Code:
      yscale(r(0.75 1))

      Comment


      • #4
        thank you for the feedback. ive try put the code in the command box but it failed.
        yscale(r(0.75 1))
        unrecognized command: yscale
        r(199);

        Comment


        • #5
          show us what your entire command was; please put inside a code box (see the FAQ if you don't know what this means)

          Comment


          • #6
            yscale(range()) is an option that you have to add to your graph command. Please read the help file and as Rich said, it is easier to help you if you show what you did.
            Code:
            help axis_scale_options

            Comment


            • #7
              Try this:
              Code:
              webuse drugtr , clear
              set seed 12345
              replace _d = 0 if runiform()>.15
              sts graph , yscale(range(0.75 1))
              Obviously, yscale() did not solve the problem. Use ylabel() instead:
              Code:
              sts graph , ylabel(.75(.05)1)
              You might even prefer to display the cumulated incidence rather than the survival:
              Code:
              sts graph , failure ylabel(0(.05)0.25)

              Comment


              • #8
                thanks you gentleman for your respond..
                Svend Juul, it worked.. thank you again..
                actually, there has a little problem.my graph is dividing into two group..
                but when i try the code, it just show one of the group.
                i send a picture to refer.

                Comment


                • #9
                  u can compare with the actualy graph

                  Comment


                  • #10
                    *actual

                    Comment


                    • #11
                      Haziq: You can edit your own posts within one hour of first posting.

                      Please post graphs as .png attachments, not photos. The FAQ Advice http://www.statalist.org/forums/help explains at Section 12.

                      Comment


                      • #12
                        orait.. im still new here, but, of course thank you for the info.

                        Comment


                        • #13
                          The most important message in the FAQ is: If a command does not work as you want, show us exactly what you wrote and what Stata responded. Now I guess: You want two survival curves in one graph, but you did not use the by() option. Read what is displayed by:
                          Code:
                          help sts graph

                          Comment


                          • #14
                            Hello,
                            I am trying to change the range of y values of these two graphs to (-5 5). I have tried using the above command, yscale(r(-5 5)), however even when using it on my full code (below) I get the following graphs. As you can see, the y axes do not range between -5 and 5 for either graph.
                            Click image for larger version

Name:	Graph no limits .png
Views:	1
Size:	143.6 KB
ID:	1749389 Click image for larger version

Name:	Graph2 no limits .png
Views:	1
Size:	172.1 KB
ID:	1749390

                            Here is my full code:

                            xtreg lpbevreg c.Eincentive##c.Hhy1000 lnprice lvwprice chinf l.chinf lrate lpratio i.year, fe robust
                            margins, dydx(Eincentive) at(Hhy1000 = (9(1)34))
                            marginsplot, yscale(range(-5 5))

                            xtreg lpbevreg c.incentive##c.Hhy1000 lnprice lvwprice chinf l.chinf lrate lpratio i.year, fe robust
                            margins, dydx(incentive) at(Hhy1000 = (9(1)34))
                            marginsplot, yscale(r(-5 5))

                            Thank you for any help you can provide.

                            Comment


                            • #15
                              A yscale() call will never omit data points from a graph. This is explained at
                              Code:
                              help axis scale options
                              What you're plotting goes outside [-5, 5]. so the most you can do is insist on a narrower range for the axis labels.

                              Comment

                              Working...
                              X