Announcement

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

  • Xlabel Bar Graph

    Why can I not change the xlabels of by bar graph from numbers to meaningful names? I get always the following error messages:

    xlabels(1 PGM" 0 "PGM invalid name
    r(198);

    Code:
     #delimit ;
    graph bar (mean) prelapse, over(pgma)
    bargap(-30)
    note("Source: Created by the author based on PGMD and UCDP data")
    scheme(s1mono)
    blabel(bar, position(outside))
    ytitle("Percentage of recurring conflicts to total number of conflicts")
    xlabel(1 "PGM" 0 "PGM absence")
    title("Relative frequencies of conflict recurrences")
    ylabel(0 "0%" 0.2 "20%" 0.4 "40%" 0.6 "60%")
    name(grapha, replace);
    #delimit cr

  • #2
    Wrong option. xlabel() is not an option of graph bar. The error message is puzzling, but the syntax is not legal.

    Comment


    • #3
      Thanks! But is there another way to label my x-axis meaningfully?

      Comment


      • #4
        Christoph Steinert if the variable displayed on the x-axis has value labels associated with the values and you have brewscheme installed you can create a theme file that will default to using the value labels:

        Code:
        // This will only modify changes from the default theme used by brewscheme and is based on the code above
        brewtheme extheme, yesno("use_labels_on_ticks yes") barlabelsty("bar bar") barlabelpos("bar outside") relsize("bar_gap -30")
        
        // Create the new theme file using a gray scale color palette for all graph types and the theme created in the line above
        brewscheme, scheme(exscheme) allsty(greys) allc(6) themef(extheme)
        
        // Create the graph with the new scheme and never have to code the same set of aesthetic settings again in the future.
        gr bar (mean) prelapse, over(pgma) note("Source: Created by the author based on PGMD and UCDP data") scheme(exscheme) ///  
        yti("Percentage of recurring conflicts to total number of conflicts") ti("Relative frequencies of conflict recurrences") name(grapha, replace)
        Haven't had a chance to test it, but assuming the values you are trying to use on the x/y axes are defined as value labels on their respective variables it should get you a good amount of the way there.

        Comment


        • #5
          See help graph_bar##axis_options . In particular, see relabel() under the over_subopts section. You will want something like:

          Code:
          ...over(pgma, relabel(0 "Text" 1 "Text") )...
          Stata/MP 14.1 (64-bit x86-64)
          Revision 19 May 2016
          Win 8.1

          Comment

          Working...
          X