6
6
# '
7
7
# ' @param base_size base font size, given in pts.
8
8
# ' @param base_family base font family
9
+ # ' @param header_family font family for titles and headers. The default, `NULL`,
10
+ # ' uses theme inheritance to set the font. This setting affects axis titles,
11
+ # ' legend titles, the plot title and tag text.
9
12
# ' @param base_line_size base size for line elements
10
13
# ' @param base_rect_size base size for rect elements
11
14
# '
101
104
# ' @export
102
105
# ' @rdname ggtheme
103
106
theme_grey <- function (base_size = 11 , base_family = " " ,
107
+ header_family = NULL ,
104
108
base_line_size = base_size / 22 ,
105
109
base_rect_size = base_size / 22 ) {
106
110
@@ -133,6 +137,9 @@ theme_grey <- function(base_size = 11, base_family = "",
133
137
lineheight = 0.9 , hjust = 0.5 , vjust = 0.5 , angle = 0 ,
134
138
margin = margin(), debug = FALSE
135
139
),
140
+
141
+ title = element_text(family = header_family ),
142
+
136
143
spacing = unit(half_line , " pt" ),
137
144
margins = margin(half_line , half_line , half_line , half_line ),
138
145
@@ -257,12 +264,14 @@ theme_gray <- theme_grey
257
264
# ' @export
258
265
# ' @rdname ggtheme
259
266
theme_bw <- function (base_size = 11 , base_family = " " ,
267
+ header_family = NULL ,
260
268
base_line_size = base_size / 22 ,
261
269
base_rect_size = base_size / 22 ) {
262
270
# Starts with theme_grey and then modify some parts
263
271
theme_grey(
264
272
base_size = base_size ,
265
273
base_family = base_family ,
274
+ header_family = header_family ,
266
275
base_line_size = base_line_size ,
267
276
base_rect_size = base_rect_size
268
277
) %+ replace %
@@ -283,6 +292,7 @@ theme_bw <- function(base_size = 11, base_family = "",
283
292
# ' @export
284
293
# ' @rdname ggtheme
285
294
theme_linedraw <- function (base_size = 11 , base_family = " " ,
295
+ header_family = NULL ,
286
296
base_line_size = base_size / 22 ,
287
297
base_rect_size = base_size / 22 ) {
288
298
half_line <- base_size / 2
@@ -292,6 +302,7 @@ theme_linedraw <- function(base_size = 11, base_family = "",
292
302
theme_bw(
293
303
base_size = base_size ,
294
304
base_family = base_family ,
305
+ header_family = header_family ,
295
306
base_line_size = base_line_size ,
296
307
base_rect_size = base_rect_size
297
308
) %+ replace %
@@ -323,6 +334,7 @@ theme_linedraw <- function(base_size = 11, base_family = "",
323
334
# ' @export
324
335
# ' @rdname ggtheme
325
336
theme_light <- function (base_size = 11 , base_family = " " ,
337
+ header_family = NULL ,
326
338
base_line_size = base_size / 22 ,
327
339
base_rect_size = base_size / 22 ) {
328
340
half_line <- base_size / 2
@@ -331,6 +343,7 @@ theme_light <- function(base_size = 11, base_family = "",
331
343
theme_grey(
332
344
base_size = base_size ,
333
345
base_family = base_family ,
346
+ header_family = header_family ,
334
347
base_line_size = base_line_size ,
335
348
base_rect_size = base_rect_size
336
349
) %+ replace %
@@ -363,6 +376,7 @@ theme_light <- function(base_size = 11, base_family = "",
363
376
# ' @export
364
377
# ' @rdname ggtheme
365
378
theme_dark <- function (base_size = 11 , base_family = " " ,
379
+ header_family = NULL ,
366
380
base_line_size = base_size / 22 ,
367
381
base_rect_size = base_size / 22 ) {
368
382
half_line <- base_size / 2
@@ -371,6 +385,7 @@ theme_dark <- function(base_size = 11, base_family = "",
371
385
theme_grey(
372
386
base_size = base_size ,
373
387
base_family = base_family ,
388
+ header_family = header_family ,
374
389
base_line_size = base_line_size ,
375
390
base_rect_size = base_rect_size
376
391
) %+ replace %
@@ -401,12 +416,14 @@ theme_dark <- function(base_size = 11, base_family = "",
401
416
# ' @export
402
417
# ' @rdname ggtheme
403
418
theme_minimal <- function (base_size = 11 , base_family = " " ,
419
+ header_family = NULL ,
404
420
base_line_size = base_size / 22 ,
405
421
base_rect_size = base_size / 22 ) {
406
422
# Starts with theme_bw and remove most parts
407
423
theme_bw(
408
424
base_size = base_size ,
409
425
base_family = base_family ,
426
+ header_family = header_family ,
410
427
base_line_size = base_line_size ,
411
428
base_rect_size = base_rect_size
412
429
) %+ replace %
@@ -426,11 +443,13 @@ theme_minimal <- function(base_size = 11, base_family = "",
426
443
# ' @export
427
444
# ' @rdname ggtheme
428
445
theme_classic <- function (base_size = 11 , base_family = " " ,
446
+ header_family = NULL ,
429
447
base_line_size = base_size / 22 ,
430
448
base_rect_size = base_size / 22 ) {
431
449
theme_bw(
432
450
base_size = base_size ,
433
451
base_family = base_family ,
452
+ header_family = header_family ,
434
453
base_line_size = base_line_size ,
435
454
base_rect_size = base_rect_size
436
455
) %+ replace %
@@ -454,6 +473,7 @@ theme_classic <- function(base_size = 11, base_family = "",
454
473
# ' @export
455
474
# ' @rdname ggtheme
456
475
theme_void <- function (base_size = 11 , base_family = " " ,
476
+ header_family = NULL ,
457
477
base_line_size = base_size / 22 ,
458
478
base_rect_size = base_size / 22 ) {
459
479
half_line <- base_size / 2
@@ -468,6 +488,7 @@ theme_void <- function(base_size = 11, base_family = "",
468
488
lineheight = 0.9 , hjust = 0.5 , vjust = 0.5 , angle = 0 ,
469
489
margin = margin(), debug = FALSE
470
490
),
491
+ title = element_text(family = header_family ),
471
492
spacing = unit(half_line , " pt" ),
472
493
margins = margin(half_line , half_line , half_line , half_line ),
473
494
axis.text = element_blank(),
@@ -530,6 +551,7 @@ theme_void <- function(base_size = 11, base_family = "",
530
551
# ' @export
531
552
# ' @rdname ggtheme
532
553
theme_test <- function (base_size = 11 , base_family = " " ,
554
+ header_family = NULL ,
533
555
base_line_size = base_size / 22 ,
534
556
base_rect_size = base_size / 22 ) {
535
557
half_line <- base_size / 2
@@ -549,9 +571,9 @@ theme_test <- function(base_size = 11, base_family = "",
549
571
lineheight = 0.9 , hjust = 0.5 , vjust = 0.5 , angle = 0 ,
550
572
margin = margin(), debug = FALSE
551
573
),
574
+ title = element_text(family = header_family ),
552
575
spacing = unit(half_line , " pt" ),
553
576
margins = margin(half_line , half_line , half_line , half_line ),
554
-
555
577
axis.line = element_blank(),
556
578
axis.line.x = NULL ,
557
579
axis.line.y = NULL ,
0 commit comments