This might be already implemented in the most recent version of Stata, but I just came across the problem that there seems to be no straightforward way to combine a kernel density plot (i.e. kdensity) with a normal distribution of the underlying variable.
Continue reading “Add normal distribution to kernel density plot in Stata”Tag: figures
Numbering in LaTeX documents
Manuscripts typically contain many different types of numbering: page numbering, sections, subsections, figures, tables etc.
Continue reading “Numbering in LaTeX documents”Supress labels in Stata figures
Supress legend elements in multiple Stata twoway figures
A great feature of Stata figures is that you can mix several plot types in one by using the twoway (...) (...)
command. If you have several plots merged into one twoway graph and also want to add a legend, the legend might become a bit crowded. In the following example, legends are specified with the , legend(lab(1 "Scatter 1") lab (4 "Scatter 2"))
option because I only wanted to mark the diamonds and circles in the legend:
Add time stamp to Stata figures
Especially in the early stages of a research project it might be good to “time stamp” figure so that you can later figure out when you created a certain figure. Of course you could just check the date in the explorer / finder, but you can also simply add a note to the figure with time and date of its creation:
Continue reading “Add time stamp to Stata figures”Subfigures in LaTeX
To combine multiple figures in one figure environment in LaTeX, e.g. to show scatter plots for different groups, the usepackage subfig
is there to help. It allows to create several subfigures while also adjusting the subtitles of each of the subfigures. Simple call the package in the preamble by adding
Recover Stata code from .gph files
If you ever found a good looking Stata figure saved as Stata’s own .gph and wondered how this was produced, you can simply look up the code that is stored in the file’s meta data.
Formatting text in Stata figures
Simple formatting for text in Stata figures
This is not really new, but still comes in handy when formatting text in Stata figures. With a relatively simple code, you can make write text bold, in italics, and even greek letters.
Continue reading “Formatting text in Stata figures”Simple formatting of table and figure captions
There is a fairly simple way to make adjustments to table and figure captions, e.g. to make the “Figure” bold or change the separator between “Figure X” and the actual caption: Continue reading “Simple formatting of table and figure captions”
Overlaying histograms in Stata
For analysing data and comparing distributions, I often want to overlay two histograms. Without further options, however, one distribution usually overlays the other and makes comparisons cumbersome. It is possible to set a few options to make the figure look nice. Continue reading “Overlaying histograms in Stata”
Formatted numbers in figure (sub)headers
There is a very nice and simple trick to include numbers (such as: number of observations, R2s or any other number that can be saved to a local) in Stata figures. While including numbers can be simply done with a local, the trick is to have them nicely formatted. I.e., to include commas in a larger number, or to have decimals rounded. Continue reading “Formatted numbers in figure (sub)headers”