2015-10-21 34 views
2

我读到这里巴蒂斯特年代gridextra的tableGrob功能出色的解释:https://github.com/baptiste/gridextra/wiki/tableGrobR gridExtra:为单个表格修改动态主题?

从他的审美格式化部分:

tt1 <- ttheme_default() 
tt2 <- ttheme_minimal() 
tt3 <- ttheme_minimal(
    core=list(bg_params = list(fill = blues9[1:4], col=NA), 
      fg_params=list(fontface=3)), 
    colhead=list(fg_params=list(col="navyblue", fontface=4L)), 
    rowhead=list(fg_params=list(col="orange", fontface=3L))) 

grid.arrange(
    tableGrob(iris[1:4, 1:2], theme=tt1), 
    tableGrob(iris[1:4, 1:2], theme=tt2), 
    tableGrob(iris[1:4, 1:2], theme=tt3), 
    nrow=1) 

我不知道是否有可能修改“关于即时”为主题特别tableGrob,例如,像:

grid.arrange(
    tableGrob(iris[1:4, 1:2], theme=tt1 + theme_default(core=list(fg_params=list(cex=0.7))), 
    tableGrob(iris[1:4, 1:2], theme=tt2), 
    tableGrob(iris[1:4, 1:2], theme=tt3), 
    nrow=1) 

的代码这最后一块是不行的,但我想要做的就是修改主题“TT1”在飞行中改变核心文本大小仅仅为FIR st tableGrob,不会永久更改主题“tt1”。

谢谢!

回答

1

主题似乎只是列表。您可以使用modifyList来更新列表的属性。例如

grid.arrange(
    tableGrob(iris[1:4, 1:2], theme=modifyList(tt1, list(core=list(fg_params=list(cex=0.7))))), 
    tableGrob(iris[1:4, 1:2], theme=tt2), 
    tableGrob(iris[1:4, 1:2], theme=tt3), 
    nrow=1)