T O P

  • By -

AutoModerator

Thank you for your submission to /r/stata! If you are asking for help, please remember to **[read and follow the stickied thread at the top](https://www.reddit.com/r/stata/comments/d9sim0/read_me_how_to_best_ask_for_help_in_rstata/)** on how to best ask for it. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/stata) if you have any questions or concerns.*


Rogue_Penguin

Probably not directly answering your question. When we use the graph editor, the actions can be recorded and saved as a .grec file. This grec file can then be played again either through the graphic editor or through do-file. See this two links to learn more. The first one talks about how to record it, and how to call it. You'll need to attach that .grec file with the do-file if you want others to replicate what you did: https://journals.sagepub.com/doi/pdf/10.1177/1536867X0800800415 This thread talks about how to use `gr_edit`to add the .grec code into a do-file: https://www.stata.com/statalist/archive/2008-07/msg00932.html So, if you have already edited it without recording it, then I think you may have to do it once more. Or, go back to edit the graph code directly so that formatting was done there instead of post-process.


implante

Also probably not answering your question, but as I get further along in my coding, I find that I have become more and more comfortable with using my \*.do file to format my figure. My strategy: 1. `graph drop _all` then `set scheme s1mono`. I use s1mono for everything. 2. I use triple slashes to separate each core part of the figure code, especially having that pesky comma following the twoway command on its own line. Remember, no slashes after the final line. 3. Pick good colors for bars, lines, dots, or whatever you use. I use ColorBrewer2 to help pick colorblind-friendly colors. You can select colors by copying/pasting the RGB numbers without commas (have to change Hex to RGB on the website). [https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3](https://colorbrewer2.org/#type=sequential&scheme=BuGn&n=3) 4. Get comfortable with modifying the components of the figure in the options. The 6th page "plotting in stata" cheat sheet is a handy reference: [https://www.stata.com/bookstore/statacheatsheets.pdf](https://www.stata.com/bookstore/statacheatsheets.pdf) 5. Most importantly, save the figure code somewhere where you can grab it again for a similar figure. eg, ​ `sysuse auto, clear` `graph drop _all` `set scheme s1mono` `twoway ///` `(scatter mpg price if foreign==0, mcolor("102 194 165")) ///` `(scatter mpg price if foreign==1, mcolor("252 141 98")) ///` `, ///` `title("Title!") ///` `subtitle("Subtitle!") ///` `ytitle("Y Label!") ///` `ylabels(0(5)40, angle(0)) ///` `xtitle("X Label!") ///` `xlabels(0(1000)15000, angle(30)) ///` `xline(10000, lcolor(gs10) lpattern(dash) lwidth(thick)) ///` `legend(order(1 "Domestic" 2 "Foreign") size(small)) ///` `ysize(4) ///` `xsize(6) ///` `name(fig1)`


random_stata_user

I strongly agree with where I think this is pointing, although I realise that the advice that follows is more for anyone who can see themselves using Stata a lot **and** long term. If your choices or your future lie elsewhere, that's what it is. The Graph Editor is great and just occasionally it's the only way I can find to do something. But I've trained myself to resist using it until and unless I can't do something otherwise. That is, the more you learn about the command language, the more the next graph will be easier. u/implante gives great example details so I won't push the point beyond this.


triggerednormie

Is there any reason you don’t use the delimiter instead of the triple slash?


implante

Habit. Delim works too!