In 2010 Vince Wiggins (StataCorp) released his utility -grc1leg- for attaching a single legend to a multi-panel array of previously created graphs. Ever since version 8, Stata's -graph ..., by()- {help graph_by} command has provided a way to accomplish this objective. But as paulvonhippel has pointed out here , there are circumstances in which one wants to make a multi-panel graph with a single legend that are difficult or impossible to accomplish with either -graph ..., by()- or -graph combine ...-. With advice from Vince Wiggins (StataCorp) , Jeff Pitblado (StataCorp) and Derek Wagner (StataCorp), I elaborated Vince's original command to make -grc1leg2-. To add options requested by paulvonhippel, I released Version 1.60 last year which accommodates all the -graph display- options. Recently Marc Kaulisch asked whether it might be possible to alter the sizes of markers and other symbols inside the legend. Version 2.11 responds to that suggestion with additional options to allow the user to alter the sizes of all the "keys" in a legend, as well as its title and subtitle if any.
In revisiting the program to allow changes to the marker sizes, I benefited from observations by Andrew Musau and Daniel Gross on a thread started by Florian Schneider that -grc1leg2-'s 4000 series errors thrown from Stata's -class- system {help class} might originate from the user's specifying the legend sub-option -order()- or from the user's use of the -grc1leg2- option -labsize()-. In tracking down and fixing these issues, I discovered that edits made by version 1.60 were not retained in the .gph files created by -grc1leg2-'s option --saving()-. Fixing this bug required learning a bit more about how Stata's class system works.
Version 2.11 adds two relevant options. One is -lmsize(size)- which allows the user to adjust the size of all the markers in the legend, as Marc Kaulisch requested. It works like option -labsize(size)-, -symxsize()- and -symysize()-, but for markers. Furthermore, I found compelling Marc's point that -grc1leg2- should reduce the size of all legend elements in the combined graph BY DEFAULT. (Stata's -gr combine-'s default behavior is to downsize all text and symbols in graphs it combines.) So I have added an option -legscale(size)- which allows the user to resize all of the elements inside the legend by the same multiplicative factor. If the user does not specify -legscale()-, -grc1leg2- guesses how much to shrink all the elements according to the number of panels in the combined graph. (This default downsizing can be suppressed by the option noautosize.)
In this revision -grc1leg2- is hopefully more polite when Stata's graphics utilities detect a class error. In some cases, -grc1leg2- detects and ignores the offending option, proceeding to create the graph with a warning message. (See Known Issue #1 in the help file.) In others, it traps the error and clears memory of scrambled memory graphs and sersets.
The help file and the dialog have also been updated. To install or update the new version:
Or just type:
Feel free to contact me here or by email with questions or issues. I would be particularly interested if users still encounter situations in which -grc1leg2- behaves impolitely.
In revisiting the program to allow changes to the marker sizes, I benefited from observations by Andrew Musau and Daniel Gross on a thread started by Florian Schneider that -grc1leg2-'s 4000 series errors thrown from Stata's -class- system {help class} might originate from the user's specifying the legend sub-option -order()- or from the user's use of the -grc1leg2- option -labsize()-. In tracking down and fixing these issues, I discovered that edits made by version 1.60 were not retained in the .gph files created by -grc1leg2-'s option --saving()-. Fixing this bug required learning a bit more about how Stata's class system works.
Version 2.11 adds two relevant options. One is -lmsize(size)- which allows the user to adjust the size of all the markers in the legend, as Marc Kaulisch requested. It works like option -labsize(size)-, -symxsize()- and -symysize()-, but for markers. Furthermore, I found compelling Marc's point that -grc1leg2- should reduce the size of all legend elements in the combined graph BY DEFAULT. (Stata's -gr combine-'s default behavior is to downsize all text and symbols in graphs it combines.) So I have added an option -legscale(size)- which allows the user to resize all of the elements inside the legend by the same multiplicative factor. If the user does not specify -legscale()-, -grc1leg2- guesses how much to shrink all the elements according to the number of panels in the combined graph. (This default downsizing can be suppressed by the option noautosize.)
In this revision -grc1leg2- is hopefully more polite when Stata's graphics utilities detect a class error. In some cases, -grc1leg2- detects and ignores the offending option, proceeding to create the graph with a warning message. (See Known Issue #1 in the help file.) In others, it traps the error and clears memory of scrambled memory graphs and sersets.
The help file and the dialog have also been updated. To install or update the new version:
Code:
view net describe grc1leg2, from("http://digital.cgdev.org/doc/stata/MO/Misc")
Code:
search grc1leg2
Comment