Announcement

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

  • Help understanding behavior of space in graph code

    Hello...

    I had a student run into a problem creating a graph when trying to apply a scheme...it wouldn't apply even though the scheme option was properly specified. I was able to solve the problem (there was a space after the over option before the parenthesis that contains the arguments and sub options) but was confused by Stata's behavior as I tried to find a solution. Here are some sample data that I'll use to reproduce the confusion in hopes that someone can give me some insight.

    Code:
    clear
    input y x1 x2
    5 0 0
    4 0 1
    6 1 0
    3 1 1
    end
    In the simplest form that I can reproduce the problem:

    Code:
    gr bar y, ///
        over (x1, gap(10)) ///
        over (x2, gap(50)) ///
        scheme(s1mono)
    Here is the resulting graph with the scheme not applied:

    Click image for larger version

Name:	graph 1.png
Views:	1
Size:	176.9 KB
ID:	1653093


    If I remove the gap suboptions, the scheme is applied:

    Code:
    gr bar y, ///
        over (x1) ///
        over (x2) ///
        scheme(s1mono)
    Click image for larger version

Name:	graph 2.png
Views:	1
Size:	162.8 KB
ID:	1653094


    If I leave the gap sub options but move the scheme option to before the over options, the scheme is applied:

    Code:
    gr bar y, scheme(s1mono) ///
        over (x1, gap(10)) ///
        over (x2, gap(50))
    Click image for larger version

Name:	graph 3.png
Views:	2
Size:	162.8 KB
ID:	1653095


    If I remove the spaces after the over options, the scheme is applied:

    Code:
    gr bar y, ///
        over(x1, gap(10)) ///
        over(x2, gap(50)) ///
        scheme(s1mono)
    Click image for larger version

Name:	graph 4.png
Views:	2
Size:	162.8 KB
ID:	1653096


    It seems that the space after the over option is causing the problem but it's the space when the gap suboption is specified. Having the scheme appear before the option sidesteps the problem somehow. I'm puzzled. I'm either missing something about Stata syntax or this is a bug. If I'm missing something, I'd love to know what it is.

    Thanks,
    Lance
Working...
X