Announcement

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

  • Editing marker symbols in Dotplot

    Dear Forum,

    I will greatly appreciate some advice about use of marker_options with dotplot. I am using the dotplot command to graph one variable (galectin) over a second variable (crp_cat). I am also encoding a third variable (sex) by use of symbols as copied below:

    # label define symbol 1 O 2 o
    # label values sex symbol
    # dotplot gal, over(crp_cat2) nx(30) m(none) mlabel(sex) mlabp(1) median center bar

    The output graph is copied below. Specifically, I am asking how I can (1) add different colors to the symbols (maroon and navy), and (2) to have a line for "bar" to denote the median.

    Thanks, in advance,
    Itai



    Click image for larger version

Name:	Gal CRP.png
Views:	2
Size:	26.1 KB
ID:	1640589
    Attached Files

  • #2
    You will not be able to do this with dotplot. Try twoway dot instead which will allow you to specify groups separately. You can add medians as range bars.

    Comment


    • #3
      I'd plot galectin 3 against CRP, whatever that is. What do you gain from tertile binning?

      If you are determined to do this, consider stripplot from SSC.

      Code:
      sysuse auto, clear
      set scheme s1color 
      stripplot mpg, over(rep78) separate(foreign) refline(lw(thick)) reflevel(median) stack centre vertical yla(, ang(h)) mc(maroon navy)

      Click image for larger version

Name:	notdotplot.png
Views:	1
Size:	38.2 KB
ID:	1640670

      Comment


      • #4
        Thank you Andrew and Nick, much appreciated.

        The tertile binning is additional to a twoway scatter plot. Regarding the stripplot command, I have an additional question and will be grateful for your further help.

        I would like to have the markers for both categories of foreign ("foreign" and "domestic") as hollow circles. I thought including msymbol(circle_hollow) would work but it does not (code copied below). How can I go about it?

        # stripplot mpg, over(rep78) separate(foreign) refline(lw(thick)) reflevel(median) stack centre vertical yla(, ang(h)) mc(maroon navy) msymbol(circle_hollow) Thanks in advance.
        Itai

        Comment


        • #5
          You have specified one symbol. Stata imputes the second symbol you never supplied. ms(Oh Oh) is what you need.

          This is generic and not specific to stripplot

          Comment


          • #6
            Thanks, thanks, and more thanks, Nick!

            Comment


            • #7
              Additional comment:

              When I ran the useful code from #3, I had problems with my data not stacking ( since the values were not exactly the same, I suppose). jitter(#) spreads the points (default is 0)

              sysuse auto, clear
              set scheme s1color
              stripplot mpg, over(rep78) refline(lw(thick)) reflevel(median) jitter(2) stack centre vertical yla(, ang(h))

              Comment


              • #8
                stack is an option of stripplot while jitter() is just a standard scatter option. Stata is going to jitter after the stack calculation.

                Some people like to jitter dotplots to shake identical points apart to get an impression of the frequencies of distinct values, but that is the point of stacking too.

                Your graph, your choices -- but my advice as command author and as a graphics fan is emphatically not to jitter if you stack. In fact, I would now never jitter dot or strip plots myself. If there are examples in the help that use jittering, that is to accommodate people who want to do it.

                Otherwise put, the graph in #3 looks clear enough to me and I can't see any reason at all to jitter. But I would say that, wouldn't I?

                Comment


                • #9
                  Thank you, Nick. I belatedly realised you did not recommend jitter and stack in combination.

                  I wanted to create the graph from post#3, but I get all points on top of each other with stipplot, and I cannot log transform the y-scale or get the straight line for the median in dotplot.
                  Can you help point out where I am mistanken?


                  clear
                  input double CD3_IL1b float groups
                  2.43728158397045 0
                  8.19175164844601 0
                  11.8175125962277 0
                  42.7577846580891 0
                  1.81458991372462 0
                  .827038858766982 2
                  62.8152422433825 1
                  21.51673148361044 1
                  15.26254613103 3
                  3.42756754047727 1
                  1.625935748847535 0
                  10.1426894886603 0
                  22.7003270727957 1
                  15.8926034360573 1
                  9.93031391383669 1
                  3.71981707382576 1
                  45.157726044376 1
                  0.17890394334684 2
                  32.2365962374479 1
                  12.439869685639 1
                  46.8464843520326 3
                  81.7432458446741 1
                  8.79686672977297 1
                  17.2136125992887 2
                  .337945330300865 1
                  29.426177234095 1
                  9.22034710973213 3
                  4.15453764678693 1
                  18.9296835452672 1
                  59.8075226276634 1
                  1.98953994885739 2
                  8.37064745313318 1
                  1.20155082865274 2
                  14.1583387588112 2
                  58.4984302928047 3
                  2.6929718200958 2
                  41.1834124507703 0
                  .441801326175204 3
                  1.29427868520175 3
                  4.49447464844936 2
                  19.4403008517425 3
                  131.852052328508 1
                  102.066483473779 1
                  199.206732622929 0
                  .183133781700471 2
                  125.079282103333 1
                  19.3783393481819 3
                  23.3198515396634 3
                  1.51371975922906 2
                  150.643007363131 1
                  44.6860861361655 1
                  20.3631916515377 3
                  end

                  niceloglabels CD3_IL1b, style(1) local(yla) powers

                  stripplot CD3_IL1b, over(groups) colorvar(groups) colorlist(edkblue ebblue eltblue gs8) center vertical reflevel(median) refline(lw(thick) lc(black)) reflinestretch(0.3) ylabel(`yla', ang(h)) yscale(log) xtitle ("") ytitle("") zsc (off) clegend(off) ztitle ("") msize(vsmall) name(g1)

                  dotplot CD3_IL1b, over(groups) median center ylabel(`yla', ang(h)) xtitle ("") ytitle("") zsc (off) clegend(off)msize(vsmall) name(g2)

                  Comment


                  • #10
                    dotplot I don't use any longer.

                    Here is what I would or might do otherwise. To get stacking you need to bin and that's easier after a transformation.

                    If the median is your reference level, why not show a median and quartiles box too?

                    I don't know the units of measurement here.

                    Code:
                    gen log_CD3_IL1b = log10(CD3_IL1b) 
                    label var log_CD3_IL1b "CD3_IL1b (!!!, log scale)"
                    
                    local yla 
                    forval y = 0/3 {
                        local yla `yla' `y' "10{sup:`y'}" 
                    }
                    
                    stripplot log_CD3_IL1b, over(groups) separate(groups) center stack width(0.1) vertical reflevel(median) refline(lw(thick) lc(black)) reflinestretch(0.3) ms(Oh Th Dh Sh) legend(off) ylabel(`yla', ang(h)) xtitle ("")  name(g1, replace)
                    
                    stripplot log_CD3_IL1b, over(groups) separate(groups) ms(Oh Th Dh Sh) legend(off) center cumul cumprob vertical box ylabel(`yla', ang(h)) xtitle ("")  name(g2, replace)
                    Click image for larger version

Name:	CD4_1.png
Views:	1
Size:	39.6 KB
ID:	1737902
                    Click image for larger version

Name:	CD4_2.png
Views:	1
Size:	44.0 KB
ID:	1737903

                    Comment


                    • #11
                      Thank you for the desired graph and suggestion. It is exactly what I wanted.

                      Comment

                      Working...
                      X