Announcement

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

  • Bold font in catplot or graph bar

    Hi all ,

    I wonder if its possible change the font type in a graph bar or in a catplot graph to bold font, example:
    Click image for larger version

Name:	Graph.png
Views:	2
Size:	16.4 KB
ID:	1606335



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte sat int eng float(leave stay female)
    4 74 4 1 1
    5 91 4 1 1
    4 76 4 1 0
    4 77 2 0 0
    4 70 4 1 0
    4 75 2 0 1
    4 75 3 1 1
    5 83 3 1 1
    3 69 3 1 1
    5 87 4 1 1
    5 89 3 1 0
    4 77 3 1 1
    3 71 4 1 1
    4 72 5 1 0
    4 78 3 1 0
    5 92 2 0 1
    5 79 5 1 1
    4 75 3 1 1
    5 84 5 1 1
    5 85 4 1 1
    5 85 4 1 0
    5 90 5 1 0
    5 87 5 1 0
    3 70 4 1 0
    5 94 5 1 1
    5 89 4 1 1
    4 75 3 1 1
    5 85 4 1 1
    1 42 2 0 1
    3 72 5 1 0
    5 92 4 1 1
    5 94 4 1 0
    4 69 4 1 0
    5 85 3 1 1
    4 78 5 1 0
    2 54 3 1 1
    5 91 3 1 1
    2 53 2 0 0
    5 83 3 1 0
    4 83 3 1 0
    5 84 4 1 0
    5 88 4 1 1
    5 80 2 0 1
    4 77 4 1 1
    2 60 3 1 1
    4 77 4 1 1
    3 65 3 1 0
    2 54 3 1 0
    5 94 3 1 1
    5 95 5 1 1
    3 59 5 1 1
    4 69 2 0 0
    5 74 1 0 1
    3 59 4 1 1
    3 70 2 0 0
    3 69 2 0 1
    3 70 3 1 1
    5 87 3 1 0
    5 93 5 1 1
    5 84 3 1 1
    3 62 4 1 1
    4 73 3 1 1
    3 68 4 1 1
    4 73 4 1 1
    4 79 4 1 1
    4 79 1 0 1
    2 54 5 1 1
    5 77 2 0 0
    5 85 4 1 0
    5 90 5 1 1
    3 69 3 1 0
    4 77 5 1 1
    2 60 3 1 1
    5 78 5 1 1
    4 75 4 1 0
    3 68 3 1 1
    3 60 4 1 1
    1 38 3 1 0
    1 37 2 0 1
    5 93 5 1 0
    5 84 4 1 1
    3 71 5 1 0
    4 81 4 1 1
    3 68 3 1 1
    4 70 3 1 0
    3 63 2 0 1
    5 86 3 1 1
    4 83 3 1 1
    3 65 4 1 0
    4 73 3 1 0
    5 89 2 0 1
    5 85 4 1 1
    4 74 3 1 0
    4 77 5 1 0
    5 75 5 1 1
    3 65 3 1 1
    5 91 4 1 0
    5 87 5 1 1
    5 83 5 1 1
    5 94 4 1 1
    end
    label values sat sat
    label def sat 1 "Very Dissatisfied", modify
    label def sat 2 "Somewhat Dissatisified", modify
    label def sat 3 "Neither Satisfied nor Dissatisfied", modify
    label def sat 4 "Somewhat Satisfied", modify
    label def sat 5 "Very Satisfied", modify
    label values leave likely
    label def likely 1 "Very likely", modify
    label def likely 2 "Somewhat likely", modify
    label def likely 3 "Neither likely nor unlikely", modify
    label def likely 4 "Somewhat unlikely", modify
    label def likely 5 "Very unlikely", modify
    label values stay stay
    label def stay 0 "Likely to Leave", modify
    label def stay 1 "Likely to Say", modify
    label values female fm
    label def fm 0 "Male", modify
    label def fm 1 "Female", modify
    
    *ssc install catplot
    
    catplot female sat, ///
    percent(female) ///
    var1opts(label(labsize(small))) ///
    var2opts(label(labsize(*1.1))) ///
    ytitle("Percent of Respondents by Gender", size(small)) ///
    title("Job Satisfaction by Gender" ///
    , span size(medium)) ///
    blabel(bar, format(%4.1f)) ///
    intensity(25)
    Attached Files

  • #2
    catplot is from SSC, as you are asked to explain (FAQ Advice #12).

    Code:
    sysuse auto, clear
    gr hbar mpg, over(rep78) over(foreign, relabel(1 "{bf: Domestic}")) nofill

    Comment


    • #3
      Thanks Andrew Musau for you reply .

      I found other alternative with elabel (SSC):

      Code:
      sysuse auto
      
      elabel define (foreign) (= #) (= "{bf:" + @ + "}") , modify
      
      gr hbar mpg, over(rep78) over(foreign)

      Comment


      • #4
        I found some problem with elabel (SSC) in the category:

        Neither Satisfied nor Dissatisfied, example:

        Code:
        elabel define (sat) (= #) (= "{bf:" + @ + "}") , modify
        
        catplot female sat, ///
        percent(female) ///
        var1opts(label(labsize(small))) ///
        var2opts(label(labsize(*1.1))) ///
        ytitle("Percent of Respondents by Gender", size(small)) ///
        title("Job Satisfaction by Gender" ///
        , span size(medium)) ///
        blabel(bar, format(%4.1f)) ///
        intensity(25)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	19.7 KB
ID:	1606343



        label list sat

        Code:
        sat:
                   1 {bf:Very Dissatisfied}
                   2 {bf:Somewhat Dissatisified}
                   3 {bf:Neither Satisfied nor Dissatisfied}
                   4 {bf:Somewhat Satisfied}
                   5 {bf:Very Satisfied}

        Comment


        • #5
          The problem is not with elabel. It did what you asked it to do. The problem is that the longest label is too long to fit in the space available. You might try editing it to fit on two lines, or abbreviate it.

          Comment


          • #6
            Thanks Nick:
            label def sat 3 "Neither Satisfied...", modify

            Comment

            Working...
            X