Announcement

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

  • Dotplots - How to have different colours in the same plot?


    Dear all I want to produce a dotplot with 2 variables next to each other (two antigens), but in each variable I have a mix of individuals from 2 groups (cohort C and D). I would like to be able to distinguish in each variable the 2 groups by using 2 colours or two different symbols. The command "by" or "over" doesn't work for dotplots. I try to use the stripplot, and by using "separate" I am able to do that have the 2 cohorts differentiate by colour, but not only the plot is horizontal instead of vertical as it seams that some dots are missing. I am also able to distiguish by colour the 2 groups using a scatter plot, so I don't understand why cannot I do the same for a dotplot. In summary: Does anyone know how to get 2 colors or 2 different symbols for markers on the same dotplot column? My initial command was dotplot PT PBS, ytitle(SFU per million PBMC) ----- but all the dots as expected in the same plot have the same colour If I write: . dotplot PTX PBS, over(cohorts) only 1 variable may be plotted with by() r(198); But for stripplot: stripplot PTX PBS, separate(cohorts) This works, but not with the layout that I wanted. I would be very grateful for your help (I am a paediatrician doing a PhD, so my stats background is from medical school and courses, so sorry if it is a silly question) Kind regards Marta

  • #2
    I am a geographer, so always underscore a medic: you should be surprised that I can read and write.

    More seriously, with stripplot (from SSC, as you are asked to explain) you should find that

    Code:
    stripplot PTX PBS, separate(cohorts) vertical
    is closer to what you want. What you are missing is explained in the help:

    vertical specifies that the magnitude axis should be vertical.
    If you show example data, with say

    Code:
    dataex PTX PBS cohorts
    then I should be able to make further suggestions.

    Comment


    • #3
      Dear Nick

      Amazed by your abilities as a geographer !

      Thank you so much for the suggestion and help! The use of vertical command made the layout exactly as I wanted but the dots very difficult to read (they are all overlapping), that is why the dot plot seems better for what I want to show.
      I used the dataex as suggested and this is my example data (not sure if I am copy and pasted properly)

      input double(PTX PBS) str1 cohorts
      5 0 "C"
      86.6666667 0 "C"
      0 5 "C"
      26.6666667 17.5 "C"
      10 0 "C"
      16.6666667 0 "C"
      0 0 "C"
      0 1.66666667 "C"
      6.66666667 1.66666667 "C"
      0 0 "C"
      1.66666667 0 "C"
      5 0 "D"
      16.66666667 0 "D"
      40 3.333333333 "D"
      3.333333333 0 "D"
      1.66666667 0 "D"
      0 0 "D"
      10 1.66666667 "D"
      13.3333333 0 "D"
      1.66666667 0 "D"
      83.3333333 0 "D"
      end


      Thank you again
      Marta

      Comment


      • #4
        Here is one suggestion:

        Code:
        stripplot PTX PBS, separate(cohorts) vertical scheme(s1color) cumul cumprob centre mla(cohorts cohorts) ms(none ..) mlabpos(0 ..) legend(off) yla(, ang(h)) xla(, noticks) ytitle(units go here)
        Click image for larger version

Name:	dotplot_ptx_pbs.png
Views:	1
Size:	23.6 KB
ID:	1451134


        What are the units? What is the range of measurement: is it [0, 100]?

        Comment


        • #5
          Thank you Nick! This gives me a much better idea of the differences so, if not possible another way is the way to go! The units are SFU (spots formating units) per million of PBMC! Depending on the antigen can go up to 100, like this one, but I have antigens that range until 1000-1500. The PBS is the negative control, so ideally we would have all 0, but give us a control for the positive antigen.


          I was looking for dotplots with the 2 colours to give as an example of what I would like to do, so I attached an image.

          Thank you again for all your help

          Kind regards
          Marta







          Attached Files

          Comment


          • #6
            Looking at this again:

            Much depends on your dataset size, whether you have shown us everything or there are many more values.

            Also, Googling PTX and PBS makes me wonder whether they have the same units of measurement. If not separate graphs seem indicated.

            Here is a script. G1 is the graph in my previous answer. G2 and G3 are below.

            stripplot won't show a box when it would be of zero height (or length). I am calling this a feature.

            Code:
            clear 
            
            input double(PTX PBS) str1 cohorts
            5 0 "C"
            86.6666667 0 "C"
            0 5 "C"
            26.6666667 17.5 "C"
            10 0 "C"
            16.6666667 0 "C"
            0 0 "C"
            0 1.66666667 "C"
            6.66666667 1.66666667 "C"
            0 0 "C"
            1.66666667 0 "C"
            5 0 "D"
            16.66666667 0 "D"
            40 3.333333333 "D"
            3.333333333 0 "D"
            1.66666667 0 "D"
            0 0 "D"
            10 1.66666667 "D"
            13.3333333 0 "D"
            1.66666667 0 "D"
            83.3333333 0 "D"
            end
            
            set scheme s1color 
            
            stripplot PTX PBS, separate(cohorts) vertical cumul cumprob centre ///
            mla(cohorts cohorts) ms(none ..) mlabpos(0 ..) legend(off)         ///
            yla(, ang(h)) xla(, noticks) ytitle(units go here) name(G1, replace) 
            
            stripplot PTX PBS, separate(cohorts) vertical width(2.5) stack ///
            mla(cohorts cohorts) ms(none ..) mlabpos(0 ..) mlabsize(small ..) legend(off)     ///
            yla(, ang(h)) xla(, ang(-.001) tlcolor(none)) ytitle(units go here) name(G2, replace)
            
            stripplot PTX, over(cohorts) cumul cumprob box centre vertical ///
            yla(, ang(h)) ytitle(PTX units go here) name(G3a, replace)
            
            stripplot PBS, over(cohorts) cumul cumprob box centre vertical ///
            yla(, ang(h)) ytitle(PBS units go here) name(G3b, replace)
            
            graph combine G3a G3b, name(G3, replace)
            Click image for larger version

Name:	dotplot_ptx_pbs_2.png
Views:	1
Size:	23.3 KB
ID:	1451182
            Click image for larger version

Name:	dotplot_ptx_pbs_3.png
Views:	1
Size:	31.8 KB
ID:	1451183

            Comment


            • #7
              On #5: I can barely read that, but options like centre stack will help you.

              Comment


              • #8
                Dear Nick

                Thank you very much! This makes all sense and graph one was exactly the format that I wanted.
                PTX is the pertussis toxin (and we are testing for the presence of cells that produce a specific antibody against this toxin) and PBS is not an antigen, is our negative control, so shouldn't mark. The comparison at this stage is just to understand if there is any background (so if the increased values on the SFU are real or just background). In the final plots, PBS will not be used since is going to be "discounted" to the value of the antigens. I would need than to compare PTX with other pertussis antigens (so I will need to use a similar code to this one)!

                Thank you!!!!! You were really helpful and this paediatrician is very thankful to stats/geographer!

                Have a lovely weekend
                Marta

                Comment

                Working...
                X