Announcement

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

  • twoway rspike for multiple y variables: add small gap between them

    I am using -twoway rspike- to plot 2 variables (with its own range) for the same values in the x-axis. I would like to see if they overlap at any point in their range

    See code below. I would like to have a small gap between the spikes of each one of the variables (for the same value in the x-axis) - just like coefplot does by default. Is this possible?

    Code:
    clear
    input str20 estimation ee_fem yhat se ci_lower ci_upper
    Linear    0    6.401265    0.0060304    6.389445    6.413084
    Linear    0.05    6.396944    0.005009    6.387127    6.406762
    Linear    0.1    6.392624    0.0039876    6.384808    6.400439
    Linear    0.15    6.388303    0.0029662    6.382489    6.394117
    Linear    0.2    6.383983    0.0019449    6.380171    6.387794
    Linear    0.25    6.379662    0.0009235    6.377852    6.381472
    Linear    0.3    6.375342    0.0000979    6.37515    6.375533
    Linear    0.35    6.371021    0.0011193    6.368827    6.373215
    Linear    0.4    6.3667    0.0021407    6.362505    6.370896
    Linear    0.45    6.36238    0.0031621    6.356182    6.368578
    Linear    0.5    6.358059    0.0041835    6.34986    6.366259
    Linear    0.55    6.353739    0.0052049    6.343537    6.36394
    Linear    0.6    6.349418    0.0062263    6.337215    6.361622
    Linear    0.65    6.345098    0.0072477    6.330893    6.359303
    Linear    0.7    6.340777    0.0082691    6.32457    6.356984
    Linear    0.75    6.336457    0.0092905    6.318248    6.354666
    Linear    0.8    6.332136    0.0103119    6.311925    6.352347
    Linear    0.85    6.327816    0.0113333    6.305603    6.350029
    Linear    0.9    6.323495    0.0123547    6.299281    6.34771
    Linear    0.95    6.319175    0.013376    6.292958    6.345391
    Linear    1    6.314854    0.0143974    6.286636    6.343073
    Squared    0    6.381992    0.0075843    6.367127    6.396857
    Squared    0.05    6.384694    0.0056836    6.373554    6.395833
    Squared    0.1    6.386485    0.0040888    6.378471    6.394499
    Squared    0.15    6.387365    0.0028755    6.38173    6.393001
    Squared    0.2    6.387336    0.0022028    6.383018    6.391653
    Squared    0.25    6.386395    0.0021825    6.382117    6.390673
    Squared    0.3    6.384544    0.0025867    6.379474    6.389614
    Squared    0.35    6.381783    0.0031176    6.375673    6.387893
    Squared    0.4    6.378111    0.0036508    6.370956    6.385266
    Squared    0.45    6.373529    0.0041705    6.365355    6.381703
    Squared    0.5    6.368036    0.00471    6.358805    6.377267
    Squared    0.55    6.361633    0.0053261    6.351194    6.372072
    Squared    0.6    6.354319    0.0060831    6.342396    6.366242
    Squared    0.65    6.346095    0.0070393    6.332298    6.359891
    Squared    0.7    6.33696    0.0082379    6.320814    6.353106
    Squared    0.75    6.326915    0.0097048    6.307894    6.345936
    Squared    0.8    6.315959    0.0114524    6.293513    6.338405
    Squared    0.85    6.304093    0.0134843    6.277664    6.330521
    Squared    0.9    6.291316    0.0157993    6.26035    6.322282
    Squared    0.95    6.277629    0.0183947    6.241576    6.313682
    Squared    1    6.263031    0.0212671    6.221348    6.304714
    end
    
    twoway (rspike ci_upper ci_lower ee_fem if estimation=="Linear") (rspike ci_upper ci_lower ee_fem if estimation=="Squared"), legend(order(1 "Linear" 2 "Squared"))

  • #2
    Code:
    . search offset , sj
    
    Search of official help files, FAQs, Examples, and Stata Journals
    
    SJ-7-1  gr0026  . . . .  Stata tip 42: The overlay problem: Offset for clarity
            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . J. Cui
            Q1/07   SJ 7(1):141--142                                 (no commands)
            tip for graphing several quantities on a continuous axis

    Comment


    • #3
      This is great, thank you!

      Comment

      Working...
      X