Announcement

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

  • [Graph] adding brackets and labels to the y-axis label

    Dear All:

    I am writing to see if there is any way for me to add brackets to the y-axis labels and group them into two groups? A nice example of my description is a graph from the presentation slides of Ben Jann's - coefplot - attached below.
    Click image for larger version

Name:	graph_example.PNG
Views:	1
Size:	62.8 KB
ID:	1459821


    This might not be directly relevant to the question, but it is actually a follow-up question following my previous post. In case it is relevant, in the previous post I have plotted a graph using the following codes provided by Carole J. Wilson.

    Code:
    clear
    input str6 varname float(b se t pvalue ll ul)
    "mpg"    -186.84166  88.17601 -2.1189625 .03769533   -362.748 -10.93533
    "trunk"   -12.72642 104.87854 -.12134439   .903771  -221.9534 196.50053
    "length"   54.55294  35.56248  1.5340027 .12960176  -16.39227 125.49815
    "turn"   -200.32475 140.01657 -1.4307218 .15702333 -479.65015  79.00066
    "_cons"    8009.893  6205.538   1.290765 .20109335  -4369.817   20389.6
    end
    
    sort b
    gen order=_n
    drop if varname=="_cons"  // ignore if you want to include the constant
    labmask order, values(varname)
    gr twoway rcap ll ul order, horiz || ///
        scatter order b , ///
        xline(0) ylab(,valuelabel angle(horizontal)) ///
        ytitle("") legend(off)
    Thank you very much and I look forward to hearing from you!

    Best regards,
    Long Hong
    Last edited by Long Hong; 27 Aug 2018, 16:29.

  • #2
    Maybe this thread will be helpful to you.
    Best regards,

    Marcos

    Comment


    • #3
      Dear Marcos Almeida, thank you for the thread! I have successfully solved the bracket problem using your post.

      I am wondering if you also know how to create vertical texts to the left of the brackets like the one in the graph. Thank you in advance!

      Best, Long

      Comment


      • #4
        I don't whether you can do this with a single-line code but perhaps you can do it manually by using the graph editor. Just click on the T toggle and see if this helps.
        Best regards,

        Marcos

        Comment


        • #5
          Here is a method. To make everything fit correctly will require trial and error.

          Code:
          gr twoway rcap ll ul order, horiz || ///
              scatter order b , ///
              xline(0) ylab(,valuelabel angle(horizontal)) ///
              ytitle("") legend(off) ///
              text( 3.5 -720 "{it:Group 1}", orientation(vertical)) ///
              text( 3.5 -700 "{subscript:|}{superscript:__________________________}{subscript:|}", orientation(vertical)) ///
              text( 2.5 -720 "{it:Group 2}", orientation(vertical)) ///
              text( 1.5 -720 "{it:Group 3}", orientation(vertical))  graphregion(margin(l+8))
          Attached Files
          Last edited by Scott Merryman; 29 Aug 2018, 08:17.

          Comment


          • #6
            Dear Scott Merryman, thank you for providing the codes. They look easy to operate and it solves my problem! - Best, Long

            Comment

            Working...
            X