![]() *A second, minor question is that I do not understand why the x-axis gets an elipsis (.) when I add the scatteri plot. I have tried adding axis(2) to the text box as an additional argument, but this option is apparently not allowed. I would like to place a label on top of a vertical line as done in the example below. It seems better to be able to attach the text to the line using the second y-axis gridpoints. Stata: Place label on top of vertical line in twoway graph. 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. What is n() for This tells Stata to draw. The corresponding lines would instead be: text(1 `median' `"median = $`=string(`median',"%6.2f")'"', /// In our case, we specified that the new plot type is a connected graph, for which you can specify marker symbols. 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. Scatteri 0 `median' 1 `median', recast(line) yaxis(2) /// Twoway hist mpg, start(10) width(5) || /// 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 |