Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Advanced features for bar chart and histogram in Stata


From   Fredrik Norström <fredrik.norstrom@epiph.umu.se>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Advanced features for bar chart and histogram in Stata
Date   Sun, 21 Aug 2011 13:22:13 +0200

Dear Statalist users,

I am struggling with generating histograms like I want them to be. To avoid a lot of manual extra work I would rather like to solve it so that Stata generates it for me. I am doubtful if that is possible but hope that at least someone can verify that for me if so.

FIRST PROBLEM:
In my questionnaire I have asked about symptoms before and after disease diagnosis. I want to generate a graph that includes 3 different symptoms (heartburn, nausea and vomiting) before and after diagnosis and the proportion of users with major problem for them. I have figured out that I can use
"graph bar (mean)  Heartburn_before Heartburn_after Nausea_before Nausea_after Vomiting_before Vomiting_after" to generate such a graph but that graph does not look like I want it to be.

I want it to be:
1) First two bars side-by-side for heartburn (to left before diagnosis and right after diagnosis) then a gap and those two for nausea side-by-side, a gap and those two for vomiting side-by-side. I have tried to use bargap but then all bars will have a difference between each other which is not what I am interested in.
2) Below bars for heartburn I want to have label "Heartburn" and similarly for nausea and vomiting. No idea how to do this right now without manually doing it in paint or another simple graphical program where I risk losing picture quality as well as having to redo everything if changes are necessary.
3) In upper right at graph I would like to have the legend with the labels "Before diagnosis" and "After diagnosis" with the colour of each of these bars. For every symptom I will have same colour for before and after diagnosis. This issue I know how I easily could solve by editing graph in Stata but would be nice to learn the code for how to specify these offsets.

I hope that I despite the lack of an illustration have managed to explain what I am interested in.

SECOND PROBLEM:
The other graph I am preparing for my paper looks at relation between diagnosis for two diseases. The graph should illustrate what disease that causes the other one. Also this problem I have solved it with histogram option in Stata. However, I am interested in making the graph more advanced. I would like it to be light color if one disease occurs before the other and a dark color if other disease occurs first. Is it possible to have a legend for a histogram where colors are different for different values?

Best regards,

Fredrik 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index