Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: scatter with aweight - consistent sizing across subsets of observations


From   "Steichen, Thomas J." <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: scatter with aweight - consistent sizing across subsets of observations
Date   Thu, 26 Mar 2009 16:10:42 -0400

The following bit of code comes from a trace of a plot with symbols sized by a weight variable. While I have not explored how the code works, I believe the early part of this sequence is the controlling logic. Perhaps you can sort out your issue  using this.

Tom


- ._draw_weighted_points
  --------------------------------------- begin yxview._draw_weighted_points ---
  - version 8
  - if (! 0`.style.marker.drawn') exit
    ------------------------------------------------ begin markerstyle.drawn ---
    - version 8
    - class exit = "`.symbol.snm'" != "none" & ( "`.fillcolor.snm'" != "none" | ( "`.linestyle.snm'" != "none" & "`.linestyle.color.snm'" != "none" & "`.linestyle.pattern.snm'" != "blank") )
    = class exit = "circle" != "none" & ( "dkgreen" != "none" | ( "p1mark" != "none" & "dkgreen" != "none" & "solid" != "blank") )
    -------------------------------------------------- end markerstyle.drawn ---
  = if (! 01) exit
  - if 0`.serset[`.wvar'].min' < 0 {
  =   if 0 < 0 {
        di as error "negative weights not allowed, plot ignored"
        exit
        }
  -   local wtseries serset.sers[`.wvar']
  =   local wtseries serset.sers[3]
  -   local max = 0`.`.`.plotregion'.graphs[1]'.style.max_wted_symsize.gmval'
  =   local max = 0
  -   local max = cond(`max' , `max', 10)
  =   local max = cond(0 , 0, 10)
  -   local scale = 1.5 / sqrt(`.`wtseries'.min')
  =   local scale = 1.5 / sqrt(18)
  -   if `scale' * sqrt(`.`wtseries'.max') > `max' {
  =     if .3535533905932738 * sqrt(24) > 10 {
          local scale = `max' / sqrt(`.`wtseries'.max')
          }
  - .style.marker.setgdifull
    ------------------------------------------- begin markerstyle.setgdifull ---
    - version 8
    - .setgdi `0'
    = .setgdi
      --------------------------------------------- begin markerstyle.setgdi ---
      - version 8
      - syntax [ , Backingsymbol ]
      - if "`backingsymbol'" != "" {
      = if "" != "" {
        .backline.setgdi
        local symbol `.backsymbol.stylename'
        local symbol : subinstr local symbol "_hollow" "" , count(local ct)
        gdi symbol = `symbol'
        gdi gm_symbolsize = `.backsize.gmval'
        gdi shadepattern = pattern10
        gdi shadelevel = 100
        if 0`ct' {
        gdi shadepattern = none
        }
        else {
        .backcolor.setgdi, shade
        }
        exit
        }
      - .linestyle.setgdi
        --------------------------------------------- begin linestyle.setgdi ---
        - version 8
        - .color.setgdi , line
          ----------------------------------------------- begin color.setgdi ---
          - version 8
          - syntax [, Line Text Shade Background Foreground ]
          - local toset `line'`text'`shade'`background'`foreground'
          = local toset line
          - if "`toset'" == "" {
          = if "line" == "" {
            local toset `._type.setting'
            }
          - if "`.stylename'" == "none" {
          = if "dkgreen" == "none" {
            if ("`toset'" == "shade" | "`toset'" == "foreground" | "`toset'" == "background") gdi shadepattern = none
            else if ("`toset'" == "line") gdi linedash = 0
            exit
            }
          - if "`toset'" != "foregound" {
          = if "line" != "foregound" {
          - gdi linedash =
          - gdi `toset'rgb = `.rgb'
          = gdi linergb = 0 96 0
          - exit
          ------------------------------------------------- end color.setgdi ---
        - gdi gm_linewidth = `.width.gmval'
          ------------------------------------------------ begin gsize.gmval ---
          - version 8
          - class exit = 0`.val' * 0`._Gr_Cglobal.gmetric_mult'
          = class exit = 0.3 * 01
          -------------------------------------------------- end gsize.gmval ---
        = gdi gm_linewidth = .3
        - if ("`.color.stylename'" != "none") .pattern.setgdi
        = if ("dkgreen" != "none") .pattern.setgdi
          ----------------------------------------- begin linepattern.setgdi ---
          - version 8
          - gdi linedash = `.pattern'
          = gdi linedash =
          ------------------------------------------- end linepattern.setgdi ---
        ----------------------------------------------- end linestyle.setgdi ---
      - local symbol `.symbol.stylename'
      = local symbol circle
      - local symbol : subinstr local symbol "_hollow" "" , count(local ct)
      - gdi symbol = `symbol'
      = gdi symbol = circle
      - gdi gm_symbolsize = `.size.gmval'
        -------------------------------------------------- begin gsize.gmval ---
        - version 8
        - class exit = 0`.val' * 0`._Gr_Cglobal.gmetric_mult'
        = class exit = 01.52778 * 01
        ---------------------------------------------------- end gsize.gmval ---
      = gdi gm_symbolsize = 1.52778
      - gdi shadepattern = pattern10
      - gdi shadelevel = 100
      - if 0`ct' {
      = if 00 {
        gdi shadepattern = none
        }
      - else {
      - .fillcolor.setgdi, shade
        ------------------------------------------------- begin color.setgdi ---
        - version 8
        - syntax [, Line Text Shade Background Foreground ]
        - local toset `line'`text'`shade'`background'`foreground'
        = local toset shade
        - if "`toset'" == "" {
        = if "shade" == "" {
          local toset `._type.setting'
          }
        - if "`.stylename'" == "none" {
        = if "dkgreen" == "none" {
          if ("`toset'" == "shade" | "`toset'" == "foreground" | "`toset'" == "background") gdi shadepattern = none
          else if ("`toset'" == "line") gdi linedash = 0
          exit
          }
        - if "`toset'" != "foregound" {
        = if "shade" != "foregound" {
        - gdi linedash =
        - gdi `toset'rgb = `.rgb'
        = gdi shadergb = 0 96 0
        - exit
        --------------------------------------------------- end color.setgdi ---
      - }
      ----------------------------------------------- end markerstyle.setgdi ---
    - gdi penchange
    - gdi shadechange
    --------------------------------------------- end markerstyle.setgdifull ---
  - gdi jitterseed = `.jitterseed'
  = gdi jitterseed = 1
  - gdi gm_jitter = `.jitter'
  = gdi gm_jitter = 0
  - gdi scatterweight `.serset.id' `.xvar' `.yvar' `.wvar' `scale'
  = gdi scatterweight 0 2 1 3 .3535533905932738
  - gdi gm_jitter = 0
  ----------------------------------------- end yxview._draw_weighted_points ---

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dan Weitzenfeld
Sent: Thursday, March 26, 2009 12:23 PM
To: [email protected]
Subject: st: scatter with aweight - consistent sizing across subsets of observations

Hi All,
I am confused as to how exactly Stata determines what will be the
largest and smallest marker size when using -scatter- with aweights.
My goal is to create a series of aweighted scatterplots, each one on a
subset of my data, with the relative marker sizing consistent across
plots.  That is, if a point in my first graph and a point in my second
graph are both weighted 100, I'd like them to be the same size,
regardless of what other points are plotted on each.

My idea for how to do this is to create two fake datapoints, one equal
to the universal minimum and one equal to the universal maximum of the
weights, and to include these fake datapoints in each plot.  Since I
am copying the graphs into PowerPoint and ungrouping them anyway, I
can just delete these two fake points.

Is there any reason this should not work?
Is there a simpler way?

Thanks in advance,
Dan
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

CONFIDENTIALITY  NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index