-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathorder_views.R
More file actions
27 lines (22 loc) · 891 Bytes
/
order_views.R
File metadata and controls
27 lines (22 loc) · 891 Bytes
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
set_view_order <- function(views, order){
#Start enforcing some order. Background color has to go in back...I'd also put grid in back:
dataViews <- views[-which(names(views) %in% c("par","legend", "axis"))]
otherViews <- views[which(names(views) %in% c("par","legend", "axis"))]
for(specialCall in order){
if(specialCall %in% names(do.call(c, unname(views)))){
newView <- list()
for(i in 1:length(dataViews)){
subView <- dataViews[[i]]
if(specialCall %in% names(subView)){
specialView <- subView[specialCall]
otherViews <- subView[-which(names(subView) %in% specialCall)]
subView <- append(assign(specialCall,specialView), otherViews)
}
newView <- append(newView, list(view=subView))
}
dataViews <- newView
}
}
views <- append(dataViews, otherViews)
return(views)
}