Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: how to draw a timeline bar failure figure.
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: how to draw a timeline bar failure figure.
Date
Fri, 25 Nov 2011 08:31:36 +0000
Good clear question. Consider
gen id = _n
labmask id, values(machine_id)
twoway rbar fail_b fail_e id, horizontal barw(0.2) yla(1/5, ang(h)
val) || ///
scatter id fail_e, ms(none) mla(fail_r) mlabpos(12) mlabgap(*4) legend(off)
where -labmask- is from SJ, i.e. -search labmask- will show
SJ-8-2 gr0034 . . . . . . . . . . Speaking Stata: Between tables and graphs
(help labmask, seqvar if installed) . . . . . . . . . . . . N. J. Cox
Q2/08 SJ 8(2):269--289
outlines techniques for producing table-like graphs
with clickable download location.
On Thu, Nov 24, 2011 at 11:37 PM, G. Dai <[email protected]> wrote:
> To make my question easier to understand, let's take the following date:
> ************data begins*******
> clear
> set obs 5
> gen machine_id=""
> replace machine_id="A" in 1
> replace machine_id= "A" in 2
> replace machine_id= "B" in 3
> replace machine_id= "B" in 4
> replace machine_id= "C" in 5
>
> gen fail_begin_hour=.
> replace fail_begin_hour=0 in 1
> replace fail_begin_hour=15 in 2
> replace fail_begin_hour=3 in 3
> replace fail_begin_hour=16 in 4
> replace fail_begin_hour=9 in 5
>
> gen fail_end_hour=.
> replace fail_end_hour=15 in 1
> replace fail_end_hour=21 in 2
> replace fail_end_hour=13 in 3
> replace fail_end_hour=24 in 4
> replace fail_end_hour=17 in 5
>
> gen fail_reason=""
> replace fail_reason="Unhappy" in 1
> replace fail_reason="Nothappy" in 2
> replace fail_reason="Happy" in 3
> replace fail_reason="Very happy" in 4
> replace fail_reason="Too Happy" in 5
> ********data ends***************
> In this dataset, I have four variables and five obs. It tells which
> machin_id fails at which time period (from fail_begin_hour to
> fail_end_hour) because of the fail_reason.
>
> What I'm trying to do is to draw a 'bar' graph with hours from 0 to 24
> as the X axis, and the machine_ID on the Y-axis, showing the time
> interval when the corresponding machine is failed. And better, I want
> to show the reason of the fail just above the 'bar'.
>
> This seems an unusual figure, so any suggestions are appreciated.
*
* 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/