Needed files for examples.
[docutils/kirr.git] / sandbox / docbook / examples / report1 / charts / receive_rates_with_adj.R
blob5b2394e4d1dc77e1f9e4c8e4d5d980e8796febf8
1 path = 'receive_rate_adjusted_draft.png'\r
2 rates <- read.csv("../tables/all.csv")\r
3 x = rates$week\r
4 direct.hours <- rates$direct.hours.receive.2011\r
5 real.hours <- rates$hours.receive.2011\r
6 start <- 38\r
7 late <- direct.hours[start:52]\r
8 title='Rate Receive Adjust'\r
9 adj1 <- .455 # from earlier this year\r
10 adj2 <- .365 # from last year\r
11 indirect.late.adj1 <- late * adj1\r
12 indirect.late.adj2 <- late * adj2\r
13 late.adj1 <- indirect.late.adj1 + late\r
14 late.adj2 <- indirect.late.adj2 + late\r
15 adj1.line <- c(real.hours[1:(start - 1)], late.adj1) \r
16 adj2.line <- c(real.hours[1:(start - 1)], late.adj2) \r
17 y1 <- real.hours\r
18 y2 <- adj1.line\r
19 y3 <- adj2.line\r
20 png(file=path, width=width,\r
21 height=3.5, units="in", res=res)\r
22 y_range <- range(y1, y2,y3, na.rm=T)\r
23 xlab.text="week in year"\r
24 xlab = xlab.text\r
25 ylab = "units/man hour"\r
26 if (make.title == T ) top.margin = 3\r
27 if (make.title != T ) title="" \r
28 if (months.grid == T) bottom.margin = 6\r
29 if (months.grid == T) xlab = ''\r
30 units <- rates$units.receive.2011\r
31 y1 <- units/y1\r
32 y2 <- units/y2\r
33 y3 <- units/y3\r
34 y_range <- range(y1,y2,y3)\r
35 margins=c(bottom.margin, 4, top.margin, 0.5) \r
36 par(mar=margins) \r
37 par('family'='serif')\r
38 plot(x, type='n', xlab=xlab, ylab=ylab, las=1, main=title, ylim=c(y_range), axes=F)\r
39 axis(1, col=ax_col)\r
40 axis(2, col=ax_col, las=1, at=axTicks(2))\r
41 box(col=box_col)\r
42 abline( h=axTicks(2), lty=1, lwd=lwd_grid, col=ax_col)\r
43 lines(x,y3, type="l", col=line_colors[1], lwd=lwd, lty=line_types[1])\r
44 #lines(x,y2, type="l", col=line_colors[2], lwd=lwd, lty=line_types[2])\r
45 lines(x,y1,  col=line_colors[2], type="l", lwd=lwd, lty=line_types[2])\r
46 x.poly = c(x, rev(x))\r
47 y.poly = c(y1, rev(y3))\r
48 polygon(x.poly, y.poly, col="lightgray", border=NA)\r
49 arrows(x0=10, x1=7, y0=150, y1=150, length=.1)\r
50 text(x=10, y=150,pos=4, "migration")\r
51 arrows(x0=30, x1=35, y0=80, y1=80, length=.1)\r
52 text(x=30, y=80,pos=2, "cutover")\r
53 legend("bottomleft", c("adjusted","real"), cex=legend_font_size, \r
54  col=line_colors,  lty=line_types, bty='y', bg="white", box.lwd=box.lwd)\r
55 source("make_x_axis.R")\r
56 dev.off()\r