@@ -269,62 +269,79 @@ popTime <- function(data, time, event, censored.indicator,
269269# ' @importFrom ggplot2 margin element_blank rel %+replace%
270270theme_cb <- function (font_size = 14 , font_family = " " , line_size = 0.5 ,
271271 rel_small = 12 / 14 , rel_tiny = 11 / 14 , rel_large = 16 / 14 ) {
272- half_line <- 0.5 * font_size
273- small_size <- rel_small * font_size
274- ggplot2 :: theme_grey(base_size = font_size , base_family = font_family ) %+ replace %
275- theme(line = element_line(color = " black" , size = line_size ,
276- linetype = 1 , lineend = " butt" ), rect = element_rect(fill = NA ,
277- color = NA , size = line_size , linetype = 1 ), text = element_text(family = font_family ,
278- face = " plain" , color = " black" , size = font_size ,
279- hjust = 0.5 , vjust = 0.5 , angle = 0 , lineheight = 0.9 ,
280- margin = margin(), debug = FALSE ), axis.line = element_line(color = " black" ,
281- size = line_size , lineend = " square" ), axis.line.x = NULL ,
282- axis.line.y = NULL , axis.text = element_text(color = " black" ,
283- size = small_size ), axis.text.x = element_text(margin = margin(t = 0.25 * small_size ),
284- vjust = 1 ), axis.text.x.top = element_text(margin = margin(b = 0.25 * small_size ),
285- vjust = 0 ), axis.text.y = element_text(margin = margin(r = 0.25 * small_size ),
286- hjust = 1 ), axis.text.y.right = element_text(margin = margin(l = 0.25 * small_size ),
287- hjust = 0 ), axis.ticks = element_line(color = " black" ,
288- size = line_size ), axis.ticks.length = unit(0.5 * half_line ,
289- " pt" ), axis.title.x = element_text(margin = margin(t = 0.5 * half_line ),
290- vjust = 1 ), axis.title.x.top = element_text(margin = margin(b = 0.5 * half_line ),
291- vjust = 0 ), axis.title.y = element_text(angle = 90 ,
292- margin = margin(r = 0.5 * half_line ),
293- vjust = 1 ),
294- axis.title.y.right = element_text(angle = - 90 , margin = margin(l = 0.5 * half_line ),
295- vjust = 0 ), legend.background = element_blank(),
296- legend.spacing = unit(font_size , " pt" ), legend.spacing.x = NULL ,
297- legend.spacing.y = NULL , legend.margin = margin(0 ,
298- 0 , 0 , 0 ), legend.key = element_blank(), legend.key.size = unit(1.1 *
299- font_size , " pt" ), legend.key.height = NULL ,
300- legend.key.width = NULL , legend.text = element_text(size = rel(rel_small )),
301- legend.text.align = NULL , legend.title = element_text(hjust = 0 ),
302- legend.title.align = NULL , legend.position = " right" ,
303- legend.direction = NULL , legend.justification = c(" left" ,
304- " center" ), legend.box = NULL , legend.box.margin = margin(0 ,
305- 0 , 0 , 0 ), legend.box.background = element_blank(),
306- legend.box.spacing = unit(font_size , " pt" ), panel.background = element_blank(),
307- panel.border = element_blank(), panel.grid = element_blank(),
308- panel.grid.major = NULL , panel.grid.minor = NULL ,
309- panel.grid.major.x = NULL , panel.grid.major.y = NULL ,
310- panel.grid.minor.x = NULL , panel.grid.minor.y = NULL ,
311- panel.spacing = unit(half_line , " pt" ), panel.spacing.x = NULL ,
312- panel.spacing.y = NULL , panel.ontop = FALSE , strip.background = element_rect(fill = " grey80" ),
313- strip.text = element_text(size = rel(rel_small ),
314- margin = margin(0.5 * half_line , 0.5 * half_line , 0.5 * half_line ,
315- 0.5 * half_line )), strip.text.x = NULL , strip.text.y = element_text(angle = - 90 ),
316- strip.placement = " inside" , strip.placement.x = NULL ,
317- strip.placement.y = NULL , strip.switch.pad.grid = unit(0.5 * half_line ,
318- " pt" ), strip.switch.pad.wrap = unit(0.5 * half_line ,
319- " pt" ), plot.background = element_blank(), plot.title = element_text(face = " bold" ,
320- size = rel(rel_large ), hjust = 0 , vjust = 1 ,
321- margin = margin(b = half_line )), plot.subtitle = element_text(size = rel(rel_small ),
322- hjust = 0 , vjust = 1 , margin = margin(b = half_line )),
323- plot.caption = element_text(size = rel(rel_tiny ),
324- hjust = 1 , vjust = 1 , margin = margin(t = half_line )),
325- plot.tag = element_text(face = " bold" , hjust = 0 ,
326- vjust = 0.7 ), plot.tag.position = c(0 , 1 ), plot.margin = margin(half_line ,
327- half_line , half_line , half_line ), complete = TRUE )
272+ half_line <- 0.5 * font_size
273+ small_size <- rel_small * font_size
274+ ggplot2 :: theme_grey(base_size = font_size , base_family = font_family ) %+ replace %
275+ theme(line = element_line(color = " black" , linewidth = line_size ,
276+ linetype = 1 , lineend = " butt" ),
277+ rect = element_rect(fill = NA , color = NA , linewidth = line_size ,
278+ linetype = 1 ),
279+ text = element_text(family = font_family ,
280+ face = " plain" , color = " black" , size = font_size ,
281+ hjust = 0.5 , vjust = 0.5 , angle = 0 , lineheight = 0.9 ,
282+ margin = margin(), debug = FALSE ),
283+ axis.line = element_line(color = " black" ,
284+ linewidth = line_size ,
285+ lineend = " square" ),
286+ axis.line.x = NULL ,
287+ axis.line.y = NULL ,
288+ axis.text = element_text(color = " black" , size = small_size ),
289+ axis.text.x = element_text(margin = margin(t = 0.25 * small_size ),
290+ vjust = 1 ),
291+ axis.text.x.top = element_text(margin = margin(b = 0.25 * small_size ),
292+ vjust = 0 ),
293+ axis.text.y = element_text(margin = margin(r = 0.25 * small_size ),
294+ hjust = 1 ),
295+ axis.text.y.right = element_text(margin = margin(l = 0.25 * small_size ),
296+ hjust = 0 ),
297+ axis.ticks = element_line(color = " black" , linewidth = line_size ),
298+ axis.ticks.length = unit(0.5 * half_line , " pt" ),
299+ axis.title.x = element_text(margin = margin(t = 0.5 * half_line ),
300+ vjust = 1 ),
301+ axis.title.x.top = element_text(margin = margin(b = 0.5 * half_line ),
302+ vjust = 0 ),
303+ axis.title.y = element_text(angle = 90 ,
304+ margin = margin(r = 0.5 * half_line ),
305+ vjust = 1 ),
306+ axis.title.y.right = element_text(angle = - 90 , margin = margin(l = 0.5 * half_line ),
307+ vjust = 0 ), legend.background = element_blank(),
308+ legend.spacing = unit(font_size , " pt" ), legend.spacing.x = NULL ,
309+ legend.spacing.y = NULL ,
310+ legend.margin = margin(0 , 0 , 0 , 0 ),
311+ legend.key = element_blank(),
312+ legend.key.size = unit(1.1 * font_size , " pt" ), legend.key.height = NULL ,
313+ legend.key.width = NULL , legend.text = element_text(size = rel(rel_small )),
314+ legend.text.align = NULL , legend.title = element_text(hjust = 0 ),
315+ legend.title.align = NULL , legend.position = " right" ,
316+ legend.direction = NULL ,
317+ legend.justification = c(" left" , " center" ),
318+ legend.box = NULL ,
319+ legend.box.margin = margin(0 , 0 , 0 , 0 ), legend.box.background = element_blank(),
320+ legend.box.spacing = unit(font_size , " pt" ), panel.background = element_blank(),
321+ panel.border = element_blank(), panel.grid = element_blank(),
322+ panel.grid.major = NULL , panel.grid.minor = NULL ,
323+ panel.grid.major.x = NULL , panel.grid.major.y = NULL ,
324+ panel.grid.minor.x = NULL , panel.grid.minor.y = NULL ,
325+ panel.spacing = unit(half_line , " pt" ), panel.spacing.x = NULL ,
326+ panel.spacing.y = NULL , panel.ontop = FALSE ,
327+ strip.background = element_rect(fill = " grey80" ),
328+ strip.text = element_text(size = rel(rel_small ),
329+ margin = margin(0.5 * half_line , 0.5 * half_line , 0.5 * half_line ,
330+ 0.5 * half_line )),
331+ strip.text.x = NULL , strip.text.y = element_text(angle = - 90 ),
332+ strip.placement = " inside" , strip.placement.x = NULL ,
333+ strip.placement.y = NULL ,
334+ strip.switch.pad.grid = unit(0.5 * half_line , " pt" ),
335+ strip.switch.pad.wrap = unit(0.5 * half_line , " pt" ),
336+ plot.background = element_blank(),
337+ plot.title = element_text(face = " bold" , size = rel(rel_large ), hjust = 0 , vjust = 1 , margin = margin(b = half_line )),
338+ plot.subtitle = element_text(size = rel(rel_small ), hjust = 0 , vjust = 1 , margin = margin(b = half_line )),
339+ plot.caption = element_text(size = rel(rel_tiny ),
340+ hjust = 1 , vjust = 1 , margin = margin(t = half_line )),
341+ plot.tag = element_text(face = " bold" , hjust = 0 ,
342+ vjust = 0.7 ), plot.tag.position = c(0 , 1 ),
343+ plot.margin = margin(half_line , half_line , half_line , half_line ),
344+ complete = TRUE )
328345}
329346
330347
@@ -341,6 +358,7 @@ panelBorder <- function(color = "grey85", size = 1, linetype = 1,
341358 }
342359 theme(panel.border = element_rect(
343360 color = color , fill = NA ,
344- linetype = linetype , size = size
361+ linetype = linetype ,
362+ linewidth = size
345363 ))
346364}
0 commit comments