Announcement

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

  • scatter marker label needs "%"

    I've been looking around the web and here on statalist looking for a solution, but haven't seen solution yet...

    Producing a twoway scatter lfit graph. I need to add "%" after the numeric scatter marker label. I've attached a copy of the current graph output. Here's the relevant code currently using:

    Code:
    twoway (scatter icupcu_mystroke date, mcolor(pink) msymbol(smcircle) mlabel(icupcu_mystroke) mlabsize(medsmall) mlabcolor(black) mlabposition(3)) (lfit icupcu_mystroke date, lcolor(cranberry)), ytitle(Percent (%), size(small)) yline(98, lwidth(thin) lpattern(dash) lcolor(black)) ylabel(0(10)100, labsize(vsmall) angle(horizontal) glcolor(gs14) gmax) ymtick(##2) xtitle("") xlabel(#3, labsize(medsmall) angle(forty_five))
    Click image for larger version

Name:	twoway scatter need percent label.jpg
Views:	1
Size:	92.8 KB
ID:	1493581

    Dataset:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(icupcu_mystroke date)
    100 708
     70 709
     57 710
    end
    format %tmMonth date
    Last edited by Matthew Holzmann; 16 Apr 2019, 10:25.

  • #2

    Something like

    Code:
    gen toshow = string(numeric, "%2.0f") + "%"
    and then use toshow as a marker label variable. Note particularly the use of a format argument to get the rounding you need.

    Comment


    • #3
      That works fabulously! Thank you so much for quick response!

      Comment

      Working...
      X