FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
code/scripts/plotpendcontroller.R at master · rmlopes/code · GitHub
rmlopes
code
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
code
/
scripts
/
plotpendcontroller.R
Copy path
More file actions
More file actions
Latest commit
History
History
History
88 lines (78 loc) · 2.67 KB
Breadcrumbs
code
/
scripts
/
plotpendcontroller.R
Copy path
File metadata and controls
88 lines (78 loc) · 2.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
library(
psych
)
library(
xtable
)
library(
outliers
)
library(
tableplot
)
library(
ggplot2
)
library(
doBy
)
library(
reshape2
)
library(
grid
)
library(
gridExtra
)
library(
gtable
)
options(
width
=
256
)
CEXAXIS
<-
0.51
#
grid.newpage()
args
<-
commandArgs(
TRUE
)
separator
=
"
\n\n
"
#
evoresults = read.table(args[1], header=TRUE)
validation
=
as.matrix(read.table(
args
[
1
],
header
=
FALSE
))
vars
=
read.table(
args
[
2
],
header
=
FALSE
)
tval
=
t(
validation
)
all
=
cbind(
vars
,stack(as.data.frame(
tval
)))
all
$
V1
<-
factor
(
all
$
V1
)
all
$
V2
<-
factor
(
all
$
V2
,
levels
=
sort(unique(
all
$
V2
),
decreasing
=
TRUE
))
all
$
V3
<-
factor
(
all
$
V3
)
#
,levels=sort(unique(all$V3),decreasing=TRUE))
all
$
V4
<-
factor
(
all
$
V4
,
levels
=
sort(unique(
all
$
V4
),
decreasing
=
FALSE
))
all
$
values
<-
factor
(
all
$
values
)
all
$
Result
<-
ifelse(
all
$
values
==
0
,
"
Sucessful
"
,
"
Failed
"
)
print(
all
)
mylabels
=
c(
'
Angular velocity (º/s)
'
,
'
Velocity (m/s)
'
,
"
Cart Position (m)
"
,
"
Pole Angle (rad)
"
)
fourvarplot
<-
function
(
alldata
,
labels
){
"
Input must have the variables named V1,V2,V3,V4, and categorical Result
"
pleg
<-
ggplot(
data
=
alldata
, aes(
x
=
V4
,
y
=
V2
))
+
facet_grid(
V1
~
V3
)
+
geom_tile(aes(
fill
=
Result
))
+
theme(
panel.grid.minor
=
element_blank(),
panel.grid.major
=
element_blank())
+
scale_fill_brewer(
palette
=
"
PRGn
"
)
+
theme(
axis.text.x
=
element_text(
angle
=
-
90
))
+
xlab(
labels
[
1
])
+
ylab(
labels
[
2
])
+
opts(
aspect.ratio
=
1
)
+
theme(
legend.position
=
'
right
'
)
leg
=
gtable_filter(ggplot_gtable(ggplot_build(
pleg
)),
"
guide-box
"
)
p
<-
ggplot(
data
=
alldata
, aes(
x
=
V4
,
y
=
V2
))
+
facet_grid(
V1
~
V3
)
+
geom_tile(aes(
fill
=
Result
))
+
theme(
panel.grid.minor
=
element_blank(),
panel.grid.major
=
element_blank())
+
scale_fill_brewer(
palette
=
"
PRGn
"
)
+
theme(
axis.text.x
=
element_text(
angle
=
-
90
))
+
xlab(
labels
[
1
])
+
ylab(
labels
[
2
])
+
opts(
aspect.ratio
=
1
)
+
theme(
legend.position
=
'
none
'
)
#
get gtable object
z
<-
ggplot_gtable(ggplot_build(
p
))
#
add label for right strip
z
<-
gtable_add_cols(
z
,
z
$
widths
[[
8
]])
z
<-
gtable_add_grob(
z
,
list
(rectGrob(
gp
=
gpar(
col
=
NA
,
fill
=
gray(
0.8
))),
textGrob(
labels
[
3
],
rot
=
-
90
,
gp
=
gpar(
col
=
gray(
1
)))),
4
,
14
,
12
,
14
,
name
=
paste(runif(
2
)))
#
add label for top strip
z
<-
gtable_add_rows(
z
,
z
$
heights
[[
3
]],
2
)
z
<-
gtable_add_grob(
z
,
list
(rectGrob(
gp
=
gpar(
col
=
NA
,
fill
=
gray(
0.8
))),
textGrob(
labels
[
4
],
gp
=
gpar(
col
=
gray(
1
)))),
3
,
4
,
3
,
12
,
name
=
paste(runif(
2
)))
#
add the legend now
z
<-
gtable_add_cols(
z
,
z
$
widths
[[
8
]])
z
<-
gtable_add_grob(
z
,
leg
,
4
,
15
,
12
,
16
)
#
add margins
z
<-
gtable_add_cols(
z
, unit(
1
/
8
,
"
line
"
),
8
)
z
<-
gtable_add_rows(
z
, unit(
1
/
8
,
"
line
"
),
3
)
return
(
z
)
}
grid.newpage()
grid.draw(fourvarplot(
all
,
mylabels
))
#
#
ggsave('r0bestpendgen.pdf',plot=p)
quit()
Back
|
FazBrowse Home
|
New Git URL