*A second, minor question is that I do not understand why the x-axis gets an elipsis (.) when I add the scatteri plot. labels since they are used in graphs and tables. file path parmest, label list(parm estimate min max p) saving(marg1. While programming in Stata or even in other languages, it is often easy to. I have tried adding axis(2) to the text box as an additional argument, but this option is apparently not allowed. results in Stata than in R This is mainly because in Stata you can only. It seems better to be able to attach the text to the line using the second y-axis gridpoints. Of course, I could manually determine this value for the histogram (as I did in this example), but I plan to create a set of these graphs via a loop, such that there are a dozen or so panels. ![]() The corresponding lines would instead be: text(1 `median' `"median = $`=string(`median',"%6.2f")'"', /// Instead of "0.08" which gets my text into the correct location, I would like to use "1", as this is the maximum value of the second y-axis. This is the reason I used the second y-axis in the first place. This produces the desired graph (for the most part*):Īt issue is that I do not know the height of the histogram beforehand. begin example - sysuse auto, clear twoway kdensity mpg, /// xline(16. I think this way it is easier for the reader to decode which label belongs to which reference line. The command may be abbreviated to twoway scatter, or just scatter if that is the only plot on the graph. Scatteri 0 `median' 1 `median', recast(line) yaxis(2) /// the graph, which contains labels for the different reference lines. Stata labels the axes using the variable labels, if they are defined, or variable names if not. Twoway hist mpg, start(10) width(5) || /// This suboption must be used if you want the y-axis labels to have this orientation and you are using Stata's default scheme (see Section 1.3.6). ![]() ![]() Here is an example of my issue: sysuse auto However, I cannot seem to add text to this line using the second y-axis coordinates (it instead uses the first y-axis coordinates, even though the object it is labeling is on the second y-axis). To fix this, I am using scatteri with coordinates.īecause I do not know the height of the histogram beforehand, I set the scatteri plot to use a separate y-axis, which I have hidden. I cannot use xline() because the line falls behind the histogram, rather than on top of it. I have a plot of a histogram, to which I would like to add the median.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |