Announcement

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

  • Adjusting graph with statplot

    Hello,

    I am using the “statplot” command written by Nick Cox and Eric Booth. I am pretty close to producing the graphs I need; however I am having trouble with one of my graphs.

    e12 and p12 are continuous variables and year is binary 0= pre arab spring and 1=post arab spring. Using this command I get the first graph (attached graph 1):

    Code:
    statplot e12 p12, over(year) vertical

    Is there any way for me to adjust the code such that instead of having the “pre-arab” and “post-arab” labels below the graph I would like it as a key.


    For example, I am able to do it for my other graphs like below (attached graph 2):

    Code:
    statplot e12 p12, over(year)over(currwork) vertical
    My second question is I have read the help file for statplot and it says I can specify fweights, aweights and iweights. I am using pweights. Is there any way to specify sampling weights when using statplot?




    Attached Files

  • #2
    Thanks for your interest in this command.

    No data example here, however....

    Adding the option asyvars may do what you want, although moving direct labels to a legend seems a bad idea to me. Shortening the value label or changing the font size would be a better idea.

    pweights are not supported by statplot, which is from SSC: The provenance is more crucial than the author names, although Eric Booth really is first author; the ordering is by contribution, not alphabetical.

    Spelling "arab" rather than "Arab" may seem careless at best.

    Comment


    • #3
      Thank you for your prompt response Nick and noted with regards to authorship. Please find below an example of my dataset:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(e12 p12) int year byte currwork
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2014 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
        1.48644   3.368936 2005 0
      -.3111064   .6615502 2005 0
      -.3111064   .6615502 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064  1.7814084 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
        4.36256    5.23523 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064   4.956463 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064  1.7814084 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
       9.036225   7.248317 2005 0
        1.48644  1.7814084 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064  1.7814084 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
        1.48644 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
        1.48644  1.7814084 2005 0
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 1
      -.3111064 -.51044536 2005 0
      -.3111064 -.51044536 2005 0
      end
      label values year bar
      label def bar 2005 "Pre-Arab spring", modify
      label def bar 2014 "Post-Arab spring", modify
      label values currwork fwork
      label def fwork 0 "Unemployed", modify
      label def fwork 1 "Employed", modify
      I will be adjusting the labels to capitalise where necessary. Using the following code produces the graph I needed:

      Code:
      statplot e12 p12, over(year) asyvars  vertical
      If I may ask why It would be a bad idea to use a legend instead of the labels?

      Comment


      • #4
        Legends oblige the reader to go back and forth between the legend itself and the graph elements concerned, here bars or groups of bars. Why do that when you can label bars directly?

        Comment


        • #5
          I see what you mean, thanks Nick.

          Comment

          Working...
          X