Adding variable labels to graph axes and legend when available#2
Adding variable labels to graph axes and legend when available#2zoniusalexandr wants to merge 2 commits intomichaelstepner:masterfrom
Conversation
Previous version used only variable names to label the axes and legend entries. This commit changes the program to use variable labels if they exist, and variable names otherwise. The one exception is the label for the y-axis if there are multiple y-variables. I'll add in a for-loop sometime in the future to fix this.
Added a for loop to cover the case with multiple y-variables. Now each variable is described using the variable label, or the variable name if there is no label, using the appropriate separator.
|
Thanks, this is a good idea, and would match the behaviour of other commands (like -scatter-). I just started a new semester, so it'll be a few weeks before I get around to updating binscatter and releasing a new version. But I'll definitely include this in the next release. |
|
Excellent, I'm glad my tinkering can be of some use. Good luck in school! By the way, do you know of a good resource for writing programs in Stata? It's such a unique language, my programming experience doesn't carry over as much as I had hoped. On Mon, Feb 3, 2014 at 11:31 PM, Michael Stepner notifications@github.com
|
|
I don't know of any general references or tutorials. My own training in Stata came about through lots of practice (writing Stata code was my primary job for a year) and frequent reference to the Stata docs (help files and the PDF manuals that are linked to from the help files). I find the Stata documentation is quite good. Although not that helpful for getting used to Stata's odd syntax, I suppose. There are two resources from which I learned quite a bit about improving the efficiency of my code:
I think the main takeaway from those articles is that these programming functions are useful and often forgotten. |
These changes make binscatter use the variable label, instead of the variable name, to label the axes and the legend entries. If the variable label is empty, it uses the variable name instead. This works with "by" and with multiple y-variables.
I've tested it briefly using the examples given in the help file for binscatter, but I haven't had a chance to exhaustively test it yet. In particular, I don't know what happens when you add special characters (like quotes) to a variable label and then try this command.