grid.tables中的两个字体

时间:2018-01-15 16:09:47

标签: r font-face r-grid

我创建了一个 # This file defines the canonical configuration parameters of the application. # Symfony uses this file as a template to generate the real app/config/parameters.yml # used by the application. # See http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters parameters: # this demo application uses an embedded SQLite database to simplify setup. # in a real Symfony application you probably will use a MySQL or PostgreSQL database database_driver: pdo_sqlite database_host: 127.0.0.1 database_port: ~ database_name: symfony database_user: root database_password: ~ # the 'database_path' is only used for SQLite type databases database_path: %kernel.root_dir%/data/blog.sqlite # Uncomment these lines to use a MySQL database instead of SQLite: # # database_driver: pdo_mysql # database_host: 127.0.0.1 # database_port: null # database_name: symfony_demo # database_user: root # database_password: null # # You can even create the database and load the sample data from the command line: # # $ cd your-symfony-project/ # $ php app/console doctrine:database:create # $ php app/console doctrine:schema:create # $ php app/console doctrine:fixtures:load # If you don't use a real mail server, you can send emails via your Gmail account. # see http://symfony.com/doc/current/cookbook/email/gmail.html mailer_transport: smtp mailer_host: 127.0.0.1 mailer_user: ~ mailer_password: ~ # The code of the default language used by the application ('en' = English) locale: en # The 'secret' value is a random string of characters, numbers and symbols # used internally by Symfony in several places (CSRF tokens, URI signing, # 'Remember Me' functionality, etc.) # see: http://symfony.com/doc/current/reference/configuration/framework.html#secret secret: 'secret_value_for_symfony_demo_application' 对象来显示PowerBi中的数据帧,下面是我的代码:

grid.table

这是我的输出:

enter image description here

我想设置输出的字体样式,以便只有第一列的字体为粗体,是否有人知道如何实现这个?

由于

1 个答案:

答案 0 :(得分:2)

grid.table()只是grid.draw(tableGrob(...))

的包装器

您可以通过一些Grob手术获得理想的结果:

library(grid)
library(gridExtra)

mydf <- data.frame(id = c(1:5), value = c("A","B","C","D","E"))

mytheme <- ttheme_default(base_size = 10, 
                          core = list(fg_params=list(hjust=0, x=0.01),
                                      bg_params=list(fill=c("white", "lightgrey"))))

制作tableGrob

tg <- tableGrob(mydf, cols = NULL, theme = mytheme, rows = NULL)

编辑tableGrob(第1列是前5个插槽):

for (i in 1:5) {
  tg$grobs[[i]] <- editGrob(tg$grobs[[i]], gp=gpar(fontface="bold"))
}

我喜欢使用新页面作为示例,但您可以删除它,因为grid.table()不使用它:

grid.newpage()
grid.draw(tg)

enter image description here

相关问题