Announcement

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

  • Boxplot order changing

    Dear All
    How can I change the orders of the boxplots of this graph? I need specific order rahar than alphabatical order
    Attached Files

  • #2
    It depends on how you created the graph in the first place. If the different boxes correspond to different variables in your data set, you can just list those variables in a different order in your command: -graph box- will graph them in the same order they appear in the command.

    But if the different boxes correspond to different levels of a single variable and you used the -over()- option, then what you must do is:
    1. Create a new value label that gives the levels in the order you want them. (See -help label- if you aren't familiar with creating labels).
    2. Attach the new value label to that variable.
    3. Re-run the -graph box- command.
    Note: This assumes that the variable in the -over()- option is a numeric variable with an attached value label. If it is a string variable, then first create a new value label giving the levels in the order you want them. Then -encode- the variable using the newly created value label (-help encode- if unfamiliar) and re-run the graph box command using the newly created (-encode-d) variable in the -over()- option instead of the original string variable.

    Comment


    • #3
      In addition to Clyde Schechter's excellent advice, the command myaxis from the Stata Journal tries to make re-ordering easier by letting you create a new ordering variable. Most commonly, using a default order (especially a default alphabetical order) is rather dopey, but sorting on say medians may make more sense.

      Otherwise put, myaxis serves as a way to go through those steps, and more. But you'll need Clyde's logic if you're reluctant or unable to install Stata extras from outside your installation.

      The paper at https://journals.sagepub.com/doi/pdf...6867X211045582 covers myaxis, together with other tricks in the same territory. Note that it isn't behind a paywall. Regardless of thatthe code and help for myaxis can be downloaded from the SJ site.

      In your specific case, I don't think box plots do an especially good job of showing some important detail, although the trade-off between simplicity and informativeness is always delicate.

      Comment


      • #4
        Clyde Schechter Thanks for the advise, Yes I used Over(), after I encoded strig variables to numeric
        I'll try the Label- option
        Appreciate it

        Comment


        • #5
          Nick Cox
          Thanks for the detailed advice
          How can I show data (numbers: mean, IQR) of Boxplots using the STATA command, I mean separately, like in a table?

          Comment


          • #6
            Code:
            help tabstat

            Comment

            Working...
            X