Announcement

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

  • Overlay graphs, without the twoway command

    Dear all,

    I am trying to overlap this two graphs:

    Code:
    twoway (qfit HH_SLMPcom BSL_GDT)
    dotplot HH_SLMPcom , over(BSL_GDT)
    However, if I try with "twoway" I get the message "dotplot is not a twoway plot type"; so I am wondering how can I overlay them (not combine).
    The main graph is qfit HH_SLMPcom BSL_GDT, but I would like to display also the number of observations per each BSL_GDT using dots.

    Thanks in advance,
    Maria
    Last edited by Maria Domingo; 24 Jun 2020, 08:29.

  • #2
    I note that dotplot does not support addplot().

    However,
    stripplot from SSC does do that.

    Code:
    . sysuse auto
    (1978 Automobile Data)
    
    . dotplot mpg, over(foreign) addplot(lfit mpg foreign)
    option addplot() not allowed
    r(198);
    
      ssc install stripplot
    
    . stripplot mpg, vertical stack over(rep78) addplot(qfit mpg rep78)



    Last edited by Nick Cox; 24 Jun 2020, 09:17.

    Comment


    • #3
      Thank you very much, it works with stripplot!!

      Comment


      • #4
        Hi, can you overlay two stripplots? You cannot use overlay as it's not a twoway plot.
        I would like to format subset of data. Example (except my actual data has many more values in the over variable equivalent to rep78, and they're categorical

        sysuse auto ,clear
        des, f
        codebook foreign
        bysort foreign: sum rep78 mpg
        drop if rep78==.
        stripplot mpg if foreign==0, over(rep78) msize(tiny) mcolor (navy%20) xtitle("") xla(,labsize(small)) vertical ///
        addplot (stripplot mpg if foreign==1, over(rep78) jitter(3) msize(tiny) mcolor (green) xtitle(""))


        Thanks so much!

        Comment


        • #5
          The difference between #2 and #4 is that twoway qfit is a subcommand of twoway but stripplot is a stand-alone command; there is no twoway stripplot subcommand for this to work.

          One way to make progress here is with a by() option.

          Code:
          sysuse auto ,clear
          
          stripplot mpg if rep78 < ., by(foreign, note("") legend(off)) over(rep78) separate(foreign) cumul cumprob  mcolor(stc1 stc2) xtitle("") vertical centre xla(, nogrid) xli(1.5/4.5, lp(solid) lc(gs8) lw(vthin))

          Comment


          • #6
            Thank you very much! however I need everything in the same graph and strippolot doesn't take over options. Box plots, violin plots etc are too visually dense for the number of asyvar values i am talking about (35-70)
            I could make scatterplots by encoding the categorical variable, but i would lose the ability to automatically show central tendencies etc.
            Essentially it's important to show the underlying distribution of values over categories and on top of it evidencing those above a certain threshold that is different in each case

            Comment


            • #7
              stripplot supports over().

              Otherwise quite what you seek is unclear to me. asyvars is an option of quite different commands. Are you saying that you want a composite plot showing 35 to 70 variables at once?

              Comment


              • #8
                Nazzarena stripplot on SSC comes from a demonstration do-file. Run that and then delete graphs of no use or interest. If one isn't close enough to what you want, you could make your question specific by giving an example and saying what is different in what you want.

                Comment

                Working...
                X