-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.sample.boxplot.001.Rnw
63 lines (57 loc) · 2.05 KB
/
plot.sample.boxplot.001.Rnw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<<fig=FALSE, echo=FALSE>>=
# Author: Lighton Phiri
# Date: February 2013
# Purpose: Sample boxplot
#
# import libraries
require(tikzDevice)
require(ggplot2)
require(reshape2)
require(grid)
require(ggthemes)
# generate tikZ-LaTeX input file
###tikz('../output/plot.sample.boxplot.001.tex', width=5.5, height=3.0)
tikz('../output/plot.sample.boxplot.001.tex')
# import datafeeds
dataset <- read.table("../data/plot.sample.boxplot.001.dat", header=TRUE, sep=",")
# add dummy column for faceting
dataset["yaba"] <- "DL concepts background"
# Change variable titles
levels(dataset$Concept)[levels(dataset$Concept) == "DL"] <- "DLs"
levels(dataset$Concept)[levels(dataset$Concept) == "Preservation"] <- "Preservation"
levels(dataset$Concept)[levels(dataset$Concept) == "Metadata"] <- "Metadata"
# create coloured plot
ggplot(data=dataset,
aes(x=Concept,
y=Classification,
fill=Concept,
ymin=1,
lower=2,
middle=3,
upper=4,
ymax=5)) +
#stat_boxplot(geom='errorbar') +
#geom_boxplot(stat = "identity") +
geom_boxplot() +
stat_summary(fun.y=mean, geom="point", aes(shape="mean"), size=5, colour="white") +
scale_shape_manual("", values=("mean"=18)) +
#geom_point() +
coord_cartesian(ylim=c(0,5)) +
scale_y_discrete(breaks=c(1,5), labels=c("Novice","Expert")) +
labs(x="DL concepts", y="Number of subjects") +
facet_wrap(~ yaba) +
theme_igray() +
theme(legend.position="none",
legend.title=element_blank(),
axis.title.x=element_text(vjust=-0.8,size=14),
axis.title.y = element_text(vjust=-0.2,size=14),
axis.text.x = element_text(angle=-90, vjust=0.5),
axis.ticks.y=element_blank(),
axis.text = element_text(size=14),
strip.text = element_text(size=14),
#plot.margin=unit(c(0.2,0.15,0.8,0.8), "cm")) +
plot.margin=unit(c(0.5,0.5,0.8,0.8), "cm")) +
coord_flip() +
scale_fill_stata()
#scale_fill_grey() # add fill=Concept to activate
@