8/8/2023 0 Comments Rename x axis labels stataTitle("In general, how satisfied are you with your job?" /// Ytitle("Percent of Respondents", size(small)) /// You could also split the title into multiple lines by putting each line in its own set of quotes, but that won't be necessary here.Įach of the new options goes inside the option for the thing it controls. Reduce the size of the title using the size(medium) option.Allow the title to use the space above the axis labels (and be centered across the entire space) using the span option.Reduce the size of the y axis title using the size(small) option.Reduce the size of the category labels using the label(labsize(small)) option.Now the problem is that the text doesn't fit in the graph. Title("In general, how satisfied are you with your job?") We'll also bold the new or changed parts of each command. For this article, we'll put just one option per line, though some options will soon take more than one line. Stata graph commands often get long you can make them more readable by splitting them across multiple lines if you use /// to tell Stata the command continues on the next line. Without quotes, Stata will think you're trying to set title options. The title text doesn't always need to go in quotes, but this one does because it contains a comma. For graphs describing surveys, the question text is often a useful title. This graph is also in dire need of an overall title, which can be added using the title() option. Note that this axis will be horizontal since you're now making a horizontal graph, but it's still referred to as the y axis. Make it more clear with a ytitle() option. You can fix this problem easily and naturally by making the whole graph horizontal rather than vertical. The categories are labeled using the value labels of the sat variable, but they're unreadable because they overlap. Unfortunately, the result is not very satisfactory: By default it will tell you the percentage of observations that fall in each category. The graph bar command tell Stata you want to make a bar graph, and the over() option tells it which variable defines the categories to be described. Begin with the sat variable (job satisfaction) and the most basic bar graph: The most basic task of a bar graph is to help you understand the distribution of a single categorical variable. female: a binary variable which is 1 if the respondent is female and 0 if the respondent is male.It is 0 if the respondent said they were likely to leave and 1 otherwise. stay: a binary variable based on leave.leave: responses to the question "How likely are you to leave your job in the next year?" on a five-point scale ranging from "Very Likely" to "Very Unlikely.".eng: a numeric measure of employee engagement from 1 to 100.sat: responses to the question "In general, how satisfied are you with your job?" on a five-point scale ranging from "Very Dissatisfied" to "Very Satisfied.".It contains fictional data with 1,000 observations and four variables: You can obtain the data by typing, or more likely copying and pasting, the following in a do file: SSCC's statistical consultants have been asked to analyze several workplace surveys in recent years, so the example data we'll use has that theme (much of this article came out of our efforts to find ways to present our results to very busy leaders). This article will show you how to make a variety of useful bar graphs using Stata. They can be understood at a glance by both technical and non-technical audiences, and often tell you much more than summary statistics will. boxplot(tot_sp ~ hab, data = mydata, axis(1, at=seq(1, 2), labels = labels.Bar graphs are simple but powerful (or rather, powerful because they are simple) tools for conveying information. Some other scripts I have tried, none have worked. Script boxplot(tot_sp ~ hab, data = mydata, xlab= "Habitat Type", ylab = "Total # Species") This is the data and the code without trying to override the labels I have a number of other boxplots to do as well, some will have more than 2 values on the x axis. Basically I just want 'Riparian' to come first, then 'Floodplain'. I would like to be able to override the x labels from the data frame with my own labels OR decide the order of the values along the x axis. This puts them in the order I want but then the label isn't neat. In my data frame I changed the names to have an 'a' or 'b' at the beginning. I notice it automatically arranges the x groups in alphabetical order, which doesn't suit my needs. I am creating boxplots for some survey data in R using boxplot(). Sorry if this is very basic, but I am quite new to this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |