Announcement

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

  • -floatplot- ssc - by-option total

    Dear Nick Cox , today I try to work with -floatplot- from SSC again. In the help file you mention that the by-options should work. When I use the -total- option, the bars and bar labels mess up and it looks like all values are shown and not only the ones for -total-.

    Adjusted Example 5 in help file:
    Code:
    floatplot Preference [fw=freq], over(year) by(female, note("") total) highneg(2) fcolors(red red*0.5 blue*0.5 blue) subtitle(, fcolor(green*0.2)) name(float5_total, replace)
    It would be really cool if you are able to tweak a fix for using the -total- option into -floatplot-.

  • #2
    And I find another issue with the by-options: I cannot use quotes for -note- or -subtitle-.
    In my current plot exercise I miss the option to do a two lines -note- as note("1. line" "2. line") does not work and the opportunity to label the -subtitlte- as var label because in one of the variable labels a comma is used...

    Adjusting Example 5 see above - creates error:
    Code:
    la var female "Gender, female"
    local loc_fem : var lab female
    floatplot Preference [fw=freq], over(year) by(female, note(Gender test) subtitle(`loc_fem')) highneg(2) fcolors(red red*0.5 blue*0.5 blue) subtitle(, fcolor(green*0.2)) name(float5_female, replace)

    Comment


    • #3
      #1 You have a point. In short, the total suboption of by() is legal but useless because nothing in the code traps it and turns it into what you want, which is the whole shebang for all your data. That should be documented better, or indeed at all, but I guess I am not going to implement it unless and until its lack really annoys me because I want to do that myself.

      In any case, there is a work-around documented at

      SJ-14-1 gr0058 . . . . . Stata tip 119: Expanding datasets for graphical ends
      . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
      Q1/14 SJ 14(1):230--235 (no commands)
      tip on using the expand command for graphics

      For example.
      Code:
      sysuse auto, clear  preserve 
      expand 2
      * the replacement value should not occur in the main dataset 
      replace foreign = 2 in 75/L
      label def origin 2 "All cars", modify
      floatplot rep78 ... . ... by(foreign) 
      restore
      where the ... indicate the syntax you would use otherwise.

      #2 Other way round, this is I think your bug as you need to protect the comma with "" as in

      Code:
       
       subtitle("`loc_fem'")
      I think that should work.

      Comment


      • #4
        Originally posted by Nick Cox View Post

        #2 Other way round, this is I think your bug as you need to protect the comma with "" as in

        Code:
        subtitle("`loc_fem'")
        I think that should work.
        #1: Thank you. A good idea. I think about it.

        #2: No success on my side
        Code:
        la var female "Gender, female"
        local loc_fem : var lab female
        floatplot Preference [fw=freq], over(year) by(female, note(Gender test) subtitle(`"`loc_fem'"')) highneg(2) fcolors(red red*0.5 blue*0.5 blue) subtitle(, fcolor(green*0.2)) name(float5_female, replace)
        gets me:
        . floatplot Preference [fw=freq], over(year) by(female, note(Gender test) subtitle(`"`loc_fem'"')) highneg(2) fcolors(red red*0.5 blue*0.5 blue) subtit
        > le(, fcolor(green*0.2)) name(float5_female, replace)
        type mismatch
        r(109);

        end of do-file

        r(109);

        Comment


        • #5
          Yes, that is also my bug. Thanks for the heads-up.

          Two mentions of

          Code:
          if "`by'"
          should be

          Code:
          if `"`by'"'

          Comment


          • #6
            Originally posted by Nick Cox View Post
            Yes, that is also my bug. Thanks for the heads-up.
            Indeed, I am able to do two line -note- and a comma -subtitle- with these two changes in the -floatplot.ado- Thank you for this quick fix.

            Comment

            Working...
            X