You are not logged in. You can browse but not post. Login or Register by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the FAQ.
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:
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).
Attach the new value label to that variable.
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.
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.
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