Announcement

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

  • Prevent plot overlay in graph

    I have:

    foreach v in x1 x2 x3 {;
    graph box `v', mark(1,mlabel(id_num));
    };

    which produces a single graph with x1-x3 as separate box plots within the graph. I need to produce one graph per variable, pause (for me to look at the graph), and then create the next graph. Any help would be appreciated.

    Bill

  • #2
    Code:
    foreach var of varlist x1 x2 x3{
        graph box `var', mark(1,mlabel(id_num)) 
        sleep 2000
    }
    Please note out strong preference for full real names (see FAQ Advice #6). Hit the contact us button located at the bottom right hand side of the screen and request that your name be changed.
    Last edited by Andrew Musau; 02 Jun 2023, 14:37.

    Comment


    • #3
      This does not prevent all of the charts to appear in one graph.

      Comment


      • #4
        If you say so. I am guessing here. See FAQ Advice #12 on how to present a data example using the dataex command so I do not have to guess. From my side, I would expect that

        Code:
        graph box x1
        creates a different graph from

        Code:
        graph box x2
        as long as \(x1\neq x2\). Nothing in the code asks for the plots to be combined, as far as I can see.
        Last edited by Andrew Musau; 02 Jun 2023, 15:49.

        Comment


        • #5
          I agree with Andrew Musau. If we focus on an example we all should be able to run, then a loop over three numeric variables such as

          Code:
          sysuse auto, clear 
          
          foreach v in mpg price weight {
          graph box `v', mark(1, mlabel(make)) 
          }
          produces three graphs one after the other and only the last remains visible when the loop has finished But specifying name() gives each one a name and it remains accessible. Nothing is overlaid in either case.

          Code:
          sysuse auto, clear 
          
          foreach v in mpg price weight {
          graph box `v', mark(1, mlabel(make)) name(`v')
          }

          Comment

          Working...
          X