Announcement

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

  • Using HBOX to create box plot - changing the titles of each box by assigning a different variable to the name

    I am using the following HBOX code and do HBOX by ID. It provides the ID number for each box but i want it to instead list a name that does not vary within ID and is unique to each ID that I have stored as a variable where it currently has the ID number. How do I do that? Here is my code:

    graph hbox effect if effect < `ubound' & effect > `lbound' & D < 51, over(ID) xsize(7) ysize(8) scale(0.6) yline(`m', lpattern(solid)) saving(_authors, replace)
    Basically. I want it to make the HBOX boxplot figure where instead of having ID 1-50 as the labels for each box it instead has the stored name I have.
    That is, instead of

    ID;
    1
    2
    3
    ...

    on the left of the box plot I want

    Name1
    Name2
    Name3

    Where I have the names of each ID stored in the string variable Name but i base the plot over ID.

    Can someone please help?

  • #2
    If I understand this correctly, you can get what you want by assigning value labels. Here is a reproducible example.



    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . graph hbox mpg, over(rep78)
    
    . label def rep78 1 poor 2 adequate
    
    . label val rep78 rep78
    
    . graph hbox mpg, over(rep78)

    Comment

    Working...
    X