Announcement

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

  • Stripplot help changing marker colours

    Hi

    I am sorry to bother you, I am trying to use stripplot to do a box and whiskers with individual data points visible. I need to code it so the markers are a different colour by the group 0 and 1. I have used separate without success, ideally on the left side I would have blue circles and on the right say red X. Is there anyway to do this


  • #2
    I have included the stripplot this is my code stripplot TH171base TH171v3 TH171v5 TH171v8, by(ustekinumab) box (bfcolor(gs8)) iqr jitter(1) stack h(0.5) vertical mcolor(blue)
    Attached Files

    Comment


    • #3
      stripplot is from SSC.

      Nothing in your code asks for different colours. But when I try
      Code:
      sysuse auto, clear
      stripplot turn trunk, by(foreign) separate(foreign)
      that fails because the code is trying to stack the foreign variable twice. That may be awkward to fix, but I will have a go. I guess if I clone it first there could be a work-around.

      EDIT: Fixed, so far as I can judge. Revised files will be posted on SSC in due course.

      If it's urgent, please find an email for me and request copies.
      Last edited by Nick Cox; 11 Dec 2023, 05:08.

      Comment


      • #4
        Now that I think I've fixed the bug, I have suggestions on various levels. Clearly I don't have access to your data and I don't even know what it's about. But I have faked something loosely similar. Otherwise most of these small details are generic.

        Use variable labels and value labels to reduce or replace cryptic or repeated text. The world doesn't need to know your variable names.

        The world doesn't agree on what should be plotted outside the boxes of a box plot. Unless you explain your choice, will it be clear to readers? If you're showing all the data, do you need anything else?

        The advantage of jittering is that you can shake identical points apart by adding noise. The disadvantages of jittering are that noise isn't informative as such and may even distract from people seeing structure in the data.

        A fill colour inside the box makes it more difficult to see data points within it.


        Code:
        clear
        set obs 100
        set seed 2803 
        
        foreach v in base v3 v5 v8 {
            gen TH171`v' = runiform()^3
            label var TH171`v' "`v'"
        } 
        
        gen ustekinumab = _n > 50 
        label def ustekinumab 0 "toad" 1 "frog"
        label val ustekinumab ustekinumab 
        
        stripplot TH171*, by(ustekinumab, note("") legend(off)) ytitle(TH171) separate(ustekinumab) box cumul centre vertical variablelabels yla(0 "0" 1 "1" 0.2(0.2)0.8, format(%02.1f))  
        Click image for larger version

Name:	TH171.png
Views:	1
Size:	81.5 KB
ID:	1736745

        Comment


        • #5
          Thanks so much this is brilliant massively appreciated am very grateful

          Comment

          Working...
          X