Stata colors

Why Stata? Supported platforms. Stata Press books Books on Stata Books on statistics. Policy Contact. Bookstore Stata Journal Stata News. Contact us Hours of operation. Advanced search. Stata allows you to adjust the transparency of elements in graphs it produces. By default, elements are not transparent. That means that graphical elements on top of each other obscure each other. By changing the transparency, you can see what lies underneath, and that usually produces better-looking graphs.

By default, Stata's elements are not transparent at all, or percent opaque. In Stata, you can specify the percentage opacity. You could make them 30 percent opaque. Here is a scatterplot with marker color set just that way:. Transparency is specified as a color modifier. This time, the colors appear in the color options because that is where colors are specified for histograms:. Learn more about Stata's publication-quality graphics features.

Read more about color transparency in [G-4] colorstyle. Stata: Data Analysis and Statistical Software. Go Stata. Purchase Products Training Support Company. Stata New in Stata Why Stata? Order Stata.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I have the following bar graph and I would like to color the bar graphs A, B, C from category "1", to blue color. The bar graphs A,B,C from category "2" to green, "3" to yellow, "4" to brown, "5" to black I'm facing a really hard time trying to understand how can I do this, since when I tried to change the colors, it changes all of them to the same color What I'm trying to get here is to color the groups 1, 2, 3, 4 and 5 in different colors, but the bars must be in the same color This shows your categories 1 to 5 as different colours.

See Dimitriy Masterov's helpful answer for how to specify the colours you want. Learn more. Stata Coloring Bar graph for different categories Ask Question. Asked 2 years, 8 months ago. Active 2 years, 8 months ago. Viewed 6k times. Active Oldest Votes. If you are willing to use a legend instead of labels, here is how I might do it: sysuse auto, clear label define lab 1 "A" 2 "B" 3 "C" 4 "D" 5 "E" lab val rep78 lab graph bar mean price, over rep78 asyvars over foreign bar 1, color blue bar 2, color green bar 3, color yellow bar 4, color brown bar 5, color black legend rows 1 This yields:.

Dimitriy V. Masterov Dimitriy V. Masterov 8, 1 1 gold badge 19 19 silver badges 43 43 bronze badges.

stata colors

To show a graph, this needs to be a question, not a comment. Nick Cox Nick Cox Sign up or log in Sign up using Google. Sign up using Facebook.

How can I graph two (or more) groups using different symbols? | Stata FAQ

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.

Stata: Data Analysis and Statistical Software

Tales from documentation: Write for your clueless users. Podcast a conversation on diversity and representation.

Upcoming Events. Featured on Meta. Feedback post: New moderator reinstatement and appeal process revisions. The new moderator agreement is now live for moderators to accept across the…. Allow bountied questions to be closed by regular users. Hot Network Questions. Question feed.

stata colors

Stack Overflow works best with JavaScript enabled.Palettes s2s1s1reconomistand mono contain colors used for p1 to p15 in official Stata's schemes files. The palettes look as follows:. Palettes cblindplottig, mrctflburdand lean provide colors found in various user-contributed scheme files.

Use options n number of colorshue range of hueschromaand luminance to determine how the colors are generated.

The following example illustrates how the colors change depending on n :. Note that hue with default options produces the same colors as HCL intense. The implementation is based on R 's colorspace package. Also see hclwizard. Three types of color schemes — qualitative, sequential, and diverging — are supported. See the help file of colorpalette for details on how the colors are computed.

stata colors

For each type a number of presets are provided. Use options huechromaluminanceand power to modify the presets. See the help file of colorpalette for details. The presets look as follows:. A powerful color generator is also provided via the ipolate option. The procedure is to select a start color and an end color, and perhaps some intermediate colors, and then apply interpolation to generate a color scale. Several suboptions to select the interpolation space, to set the positions of the origin colors, or to affect the shape of the transition between the colors are available; see the help file of colorpalette for details.

Some examples are as follow:. The ColorBrewer collection is a set of color schemes developed by Cynthia Brewer and provided at colorbrewer2. The colors are licensed under Apache License Version 2. The color schemes look as follows:. For the sequential and diverging schemes, the colors depend on the size of the palette.

For example, here are the 5-color versions of the diverging schemes:. The viridis collection provides perceptually uniform colormaps from matplotliba Python 2D plotting library. The colormaps are as follows:. The matplotlib palette provides several other colormaps from matplotlib :. The ptol palette provide some color schemes suggested by Tol The selection of colors depends on the size of the palette:. The d3 palette provides some categorical D3. The lin palette provides semantic colors suggested by Lin et al.

The semantic palettes come in two versions: algorithm selected vs.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. In this case, the categorical variable nougrups4 came from a cluster analysis. A general solution would be fine, but also a specific solution to draw clusters.

Learn more. Scatter plot color by variable Ask Question. Asked 2 years ago. Active 2 years ago. Viewed 3k times. I want to make an scatter plot in Stata with points colored according to a categorical variable.

The only way I've found to do this, is to code colors in layers of a twoway plot. Pearly Spencer Pere Pere 4 4 silver badges 15 15 bronze badges. You could create a wrapper program for the twoway scatter command to do this automatically. I suppose I could. However I want to confirm that there is not a simple built in solution to do it that I'm missing.

Other statistical packages simpler and cheaper than Stata have that feature. For example, I remember using it in Statgraphics, R both base graphics and ggplot2 and even RCommander. Even in Excel you can plot an scatterplot with categories as colors. I am not sure what is so complicated about the above syntax. In any case i provide a simple example in my answer below. In general different colo[u]rs may not work well and it's better to think in the first instance of different point or marker symbols.

Your own tentative code uses both red and green but it is, or should be, well known that many people find it difficult to distinguish between them. Active Oldest Votes. This is how I would do this by hand: sysuse auto, clear separate price, by rep78 tw scatter price? Or in one line using Nick Cox's sepscatter command from SSC: sepscatter price mpg, separate rep78 The latter command can also output other type of plots with the recast option.

Dimitriy V. Masterov Dimitriy V. Masterov 8, 1 1 gold badge 19 19 silver badges 43 43 bronze badges.Suppose we are using the high school and beyond data file hsb2 which has test scores for students, 91 males and females.

We could make a graph of their read and write score as shown below with the graph command. Say we want to see the scores separately for the males and the females. One way we can do this is by using two scatter commands, one making a graph for the males and one making a graph for the females, and overlaying these two graphs, as illustrated below.

However, one problem with the graph above is that it does not identify which markers are the males and which are the females. We can add a legend option to more clearly label the males and females, as shown below.

We can use the msymol option to control the marker symbols for the males and females. Here we plot the males with large hollow circles and the females with large solid squares. Another strategy we can use is via the separate command to make a read score for the males, and a read score for the females. We can then graph these two variables, and then get separate symbols for the males and females.

Below we use the separate command and it makes a variable read0 that is the reading score for the males and read1 that is the reading score for the females.

Now, we can graph read0 and read1 as shown below. Note that since Stata uses the variable label in the legend, it provides an indication of which symbol is the males and which is for the females.

We can use the msymbol option to select the symbols we want for males and females. Below we choose a large hollow circle Oh for the males and a large solid square S for the females.Everybody else may wish to give it a pass. Some preliminary tricks, then the code. Trick 1 that I have learned is to generate self-labeling lines by creating a variable that has the label only in the last value of the x-axis variable, year in my case.

Or self-labeling scatterplots by having a label for all values. In this code, each line gets added to the macro plotlist. Numbers less than 1 lighten the color and numbers greater than 1 darken the color.

But I wanted to see ranges of colors using the intensity values across several different named colors. I also tested creating my own color uwred and saving it in a. My application has too many values to use just color or so I judged so I also used line type. Thus the code to generate sample lines.

This is the problem that started me on this path. Letting Stata choose the colors generates an unreadable hash. After working on this problem a while, I realized the graph could be more meaningful if similar offenses had related colors. Generating a variable-specific palette is easy using the skills developed above.

Step 1: Create a spreadsheet with the variable names and labels plus columns for variable groups, color name hueintensity, line type, and the order in which I wanted the graphs to appear in my sample.

This last is to put the colors that might be difficult to distinguish next to each other in the sample. In my spreadsheet, I put different possible color schemes in different tabs. Here is one sample. The do file reads the spreadsheet with a local parameter that selects the tab and generates a sample plot. These local macros can then be used in the production graphs with the same code logic as was used to generate the samples.

When I used the most straightforward syntax, Stata eliminated the spaces between the numbers a very odd behavior! However, if you use ado files you can find on line to create and save new colors with names, those new colors should work fine with this routine.

If you examine the color-NAME. Both ado files read the RGB code for the base color from the color. By experimentation with putting values into palette colorI learned that an intensity greater than 1 consistently divides the RGB values by that number e.You want a graph that most effectively communicates your message.

You want a graph that fits the style of your journal.

Learn STATA in 15 minutes

You want a graph with colors that everyone can differentiate. Or you want a graph in grayscale. In any case, you start with a graph of your data or results, and you need to transform that graph into the style you want.

To demonstrate, I use a graph with overlaid scatterplots, model fit lines, and a confidence interval. To obtain the graph, I type. By changing the graph scheme, I can easily change the overall look of my graph. To obtain the set of graphs above, I typed. The s2color scheme is the default when you install Stata.

This is the scheme that created the graph at the top. The set scheme command changes the default graph style.

Custom color scheme for your Stata graphs, and matching colors in PowerPoint

Stata provides 11 schemes from which you can choose; these schemes are discussed in [G-4] schemes intro. This is where you will find information on using the economist and s1rcolor schemes that I used above.

The schemes provided by Stata are only a starting point. The uncluttered scheme was provided by Gray Kimbrough. If you like the style of one of the last four graphs, you can simply download and install the corresponding scheme and set it as your scheme before creating your graphs.

If none of these schemes create the style you want, try typing search scheme in Stata to locate and install other schemes. And if none of those schemes are quite what you had in mind, you can write your own scheme. To learn about this, type. It will guide you through the process. You can point and click to accomplish the same goal. You start by drawing a graph. Then, open the Graph Editor and make your changes.


thoughts on “Stata colors

Leave a Reply

Your email address will not be published. Required fields are marked *