Announcement

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

  • Marginal distributions in scatterplot

    I'd like to add marginal distributions of the X and Y variables to a scatterplot. Here's a beautiful example from Nosek et al (2015), who drew it in R.

    Is there a way to get a similar sort of graph in Stata? I don't need to do everything Nosek et al did, but I would like some visualization of the marginal distribution (a histogram, rugplot, violinplot, or kernel density plot).

    I did find -binscatterhist-, which I like, but I think it bins the scattered points, which I don't want to do.
    Click image for larger version

Name:	Marginal scatter.png
Views:	1
Size:	109.9 KB
ID:	1782687

  • #2
    If you want a data example, a convenient one is:
    Code:
    sysuse auto
    scatter mpg weight
    Now how to add marginal distributions?

    Comment


    • #3
      The Stata manual lists a similar example on page 5 here: https://www.stata.com/manuals13/g-2graphcombine.pdf
      Best wishes

      Stata 18.0 MP | ORCID | Google Scholar

      Comment


      • #4
        Not everything you seek, but in similar territory:

        SJ-25-2 gr0101 Tip 162: Add marginal rugs using marker symbols or axis ticks
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
        Q2/25 SJ 25(2):491--497 (no commands)
        tip on adding marginal rugs using marker symbols or axis ticks


        SJ-21-3 gr0088 . Adding marg. spike histograms to quantile & cum. dist. plots
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
        Q3/21 SJ 21(3):838--846 (no commands)
        tip on adding marginal spike histograms to quantile and
        (empirical) cumulative distribution (function) plots

        Comment

        Working...
        X