Announcement

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

  • Bug? ndots(0) still showing dots

    Hi everyone,

    I believe I found a small graphical bug in the ndots() option when using twoway hist, recast(dot).

    As per the manual "ndots(#) specifies the number of dots across a line; ndots(75) is the default."
    However, ndots(0) actually shows me a single line of dots at y=0, whereas ndots(1) shows zero dots.

    Here is my code, but with an example dataset (only works via editor, not directly in command window).

    Code:
    sysuse auto2
    * I am binning length here because in my own dataset I similarly use 15 groups
    egen length_binned = cut(length), group(15) label
    
    * I want to convey the distribution of a binned variable, for 2 groups (note that in my own dataset I actually have 6 groups; I prefer to overlay instead of 6 side-by-side).
    twoway ///
    (hist length_binned if foreign == 0, discrete percent xlabel(0(1)14, valuelabel)) ///
    (hist length_binned if foreign == 1, discrete percent xlabel(0(1)14, valuelabel) fcolor(none) lcolor(blue) legend(order(1 "Domestic cars" 2 "Foreign cars")))
    
    * but I don't like the look of bars/histogram so I recast into a dotplot
    * here is the graphical bug: the plot still shows dots at y=0 axis
    twoway ///
    (hist length_binned if foreign == 0, discrete percent xlabel(0(1)14, nogrid valuelabel) ylabel(, nogrid) recast(dot) ndots(0) mcolor(red) ms(Oh)) ///
    (hist length_binned if foreign == 1, discrete percent xlabel(0(1)14, valuelabel) recast(dot) ndots(0) mcolor(blue) ms(Th) legend(order(1 "Domestic cars" 2 "Foreign cars")))
    
    * switching ndots(0) to ndots(1) fixes it. I don't see any dots
    twoway ///
    (hist length_binned if foreign == 0, discrete percent xlabel(0(1)14, nogrid valuelabel) ylabel(, nogrid) recast(dot) ndots(1) mcolor(red) ms(Oh)) ///
    (hist length_binned if foreign == 1, discrete percent xlabel(0(1)14, valuelabel) recast(dot) ndots(1) mcolor(blue) ms(Th) legend(order(1 "Domestic cars" 2 "Foreign cars")))

    So, in short, I don't have a question here because ndots(1) gives me what I want (zero dots).
    But given that I spent a good chunk of time I'm curious what Statalisters/Nick Cox might think of this: is this a bug or am I missing something?

    Thanks

  • #2
    I don't follow this. Trying this in Stata 17


    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . egen rank = rank(mpg) if foreign
    (52 missing values generated)
    
    . twoway dot mpg rank
    
    . twoway dot mpg rank, ndots(0)
    I see no dots.

    Comment


    • #3
      I still see 13 pixels/dot at the y=10 line, in this case, so just above the x-axis. I am using Stata 17. The dots show on both my laptop screen and 2nd screen, regardless of .gph, .png or .emf.

      Code:
      sysuse auto, clear
      
      egen rank = rank(mpg) if foreign
      
      twoway dot mpg rank
      
      twoway dot mpg rank, ndots(0)

      Please remove the gridlines; it should become easier to spot:
      Code:
      twoway dot mpg rank, ndots(0) xla(, nogrid) yla(, nogrid)
      Weirdly enough, ndots(1) fixes it for me:
      Code:
      twoway dot mpg rank, ndots(1) xla(, nogrid) yla(, nogrid)
      .


      I'm aware the pixels/dots are super tiny; not really an issue. However, when you overlay multiple (dot graphs) in twoway, the dots become bolder and distracting.

      Comment

      Working...
      X