Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • by()-option in twoway graphs: Getting rid of the boc around the title

    Dear Statalisters,

    I have a rather simple question about formatting graphs, but I couldn'f figure it out myself and using the forum's search function didn't yield the desired results.
    So, here it comes:

    I am using the by() option in a twoway graph to get seperate graphs by an indicator variable. Apparently, some things related to the overall look of the graph need to be specified within the by()-option, e.g. turning of the default note or getting the background in white (see example below).

    Now, I would also like to get rid of the coulored text boxes around the title of the subgraphs (blue boxes aroung "Domestic" and "Foreign").
    I tried adding things like title(nobox) or title(fcolor(white) bcolor(white)) inside the by() option but that didn't work out. Adding these in the options of the whole graph did'nt work either (i.e. a line like title(fcolor(white) bcolor(white)) below the legend() option in the example).

    Does anybody know how to turn off these boxes?

    Thank you in advance and best regards,
    Boris


    Example Code:
    Code:
    sysuse auto, clear
    twoway (scatter price mpg, by(foreign, note("") graphregion(color(white)))) ///
                (lfit price mpg), ///
                legend(region(lcol(white)))
    Example output (blue circles and X's added by hand to stress how badly I need to get rid of these boxes):
    Attached Files
    Last edited by Boris Ivanov; 28 Oct 2019, 09:44. Reason: added tags, corrected typo

  • #2
    This does the trick.
    Code:
    cls
    sysuse auto, clear
    twoway (scatter price mpg, by(foreign, note("") graphregion(color(white)))) ///
                (lfit price mpg), ///
                subtitle(,bcolor(white)) ///
                legend(region(lcol(white)))
    I got it by trial-and-error looking at the output in the Graph Editor. I saw that two text boxes are each a graph subtitle over a scatterplot, so that suggested to me that the color needed to be specified at a higher level than the individual plot.

    Trial and error while pondering the Graph Editor is the story of my Stata Graphics life. And under dire circumstances I've banged on the Graph Editor until I got what I wanted for a one-off task, and never figured out how to modify the command to get it right to being with - i just documented what I'd banged on with a comment in the code in case I needed to run it again.

    Comment


    • #3
      Thank you very much, William! I completely overlooked that there is also a subtitle option, too. Thanks for the advice, next time I'll try fiddling around with the Graph Editor.

      Comment

      Working...
      X