6
6
# '
7
7
# ' @param base_size base font size
8
8
# ' @param base_family base font family
9
+ # ' @param base_line_size base size for line elements
10
+ # ' @param base_rect_size base size for rect elements
9
11
# '
10
12
# ' @details
11
13
# ' \describe{
64
66
# ' @include theme.r
65
67
# ' @export
66
68
# ' @rdname ggtheme
67
- theme_grey <- function (base_size = 11 , base_family = " " ) {
69
+ theme_grey <- function (base_size = 11 , base_family = " " ,
70
+ base_line_size = base_size / 22 ,
71
+ base_rect_size = base_size / 22 ) {
68
72
half_line <- base_size / 2
69
73
70
74
theme(
71
75
# Elements in this first block aren't used directly, but are inherited
72
76
# by others
73
- line = element_line(colour = " black" , size = 0.5 , linetype = 1 ,
74
- lineend = " butt" ),
75
- rect = element_rect(fill = " white" , colour = " black" ,
76
- size = 0.5 , linetype = 1 ),
77
+ line = element_line(
78
+ colour = " black" , size = base_line_size ,
79
+ linetype = 1 , lineend = " butt"
80
+ ),
81
+ rect = element_rect(
82
+ fill = " white" , colour = " black" ,
83
+ size = base_rect_size , linetype = 1
84
+ ),
77
85
text = element_text(
78
86
family = base_family , face = " plain" ,
79
87
colour = " black" , size = base_size ,
@@ -177,9 +185,16 @@ theme_gray <- theme_grey
177
185
178
186
# ' @export
179
187
# ' @rdname ggtheme
180
- theme_bw <- function (base_size = 11 , base_family = " " ) {
188
+ theme_bw <- function (base_size = 11 , base_family = " " ,
189
+ base_line_size = base_size / 22 ,
190
+ base_rect_size = base_size / 22 ) {
181
191
# Starts with theme_grey and then modify some parts
182
- theme_grey(base_size = base_size , base_family = base_family ) %+ replace %
192
+ theme_grey(
193
+ base_size = base_size ,
194
+ base_family = base_family ,
195
+ base_line_size = base_line_size ,
196
+ base_rect_size = base_rect_size
197
+ ) %+ replace %
183
198
theme(
184
199
# white background and dark border
185
200
panel.background = element_rect(fill = " white" , colour = NA ),
@@ -198,10 +213,17 @@ theme_bw <- function(base_size = 11, base_family = "") {
198
213
199
214
# ' @export
200
215
# ' @rdname ggtheme
201
- theme_linedraw <- function (base_size = 11 , base_family = " " ) {
216
+ theme_linedraw <- function (base_size = 11 , base_family = " " ,
217
+ base_line_size = base_size / 22 ,
218
+ base_rect_size = base_size / 22 ) {
202
219
# Starts with theme_bw and then modify some parts
203
220
# = replace all greys with pure black or white
204
- theme_bw(base_size = base_size , base_family = base_family ) %+ replace %
221
+ theme_bw(
222
+ base_size = base_size ,
223
+ base_family = base_family ,
224
+ base_line_size = base_line_size ,
225
+ base_rect_size = base_rect_size
226
+ ) %+ replace %
205
227
theme(
206
228
# black text and ticks on the axes
207
229
axis.text = element_text(colour = " black" , size = rel(0.8 )),
@@ -224,9 +246,16 @@ theme_linedraw <- function(base_size = 11, base_family = "") {
224
246
225
247
# ' @export
226
248
# ' @rdname ggtheme
227
- theme_light <- function (base_size = 11 , base_family = " " ) {
249
+ theme_light <- function (base_size = 11 , base_family = " " ,
250
+ base_line_size = base_size / 22 ,
251
+ base_rect_size = base_size / 22 ) {
228
252
# Starts with theme_grey and then modify some parts
229
- theme_grey(base_size = base_size , base_family = base_family ) %+ replace %
253
+ theme_grey(
254
+ base_size = base_size ,
255
+ base_family = base_family ,
256
+ base_line_size = base_line_size ,
257
+ base_rect_size = base_rect_size
258
+ ) %+ replace %
230
259
theme(
231
260
# white panel with light grey border
232
261
panel.background = element_rect(fill = " white" , colour = NA ),
@@ -253,9 +282,16 @@ theme_light <- function(base_size = 11, base_family = "") {
253
282
254
283
# ' @export
255
284
# ' @rdname ggtheme
256
- theme_dark <- function (base_size = 11 , base_family = " " ) {
285
+ theme_dark <- function (base_size = 11 , base_family = " " ,
286
+ base_line_size = base_size / 22 ,
287
+ base_rect_size = base_size / 22 ) {
257
288
# Starts with theme_grey and then modify some parts
258
- theme_grey(base_size = base_size , base_family = base_family ) %+ replace %
289
+ theme_grey(
290
+ base_size = base_size ,
291
+ base_family = base_family ,
292
+ base_line_size = base_line_size ,
293
+ base_rect_size = base_rect_size
294
+ ) %+ replace %
259
295
theme(
260
296
# dark panel
261
297
panel.background = element_rect(fill = " grey50" , colour = NA ),
@@ -280,9 +316,16 @@ theme_dark <- function(base_size = 11, base_family = "") {
280
316
281
317
# ' @export
282
318
# ' @rdname ggtheme
283
- theme_minimal <- function (base_size = 11 , base_family = " " ) {
319
+ theme_minimal <- function (base_size = 11 , base_family = " " ,
320
+ base_line_size = base_size / 22 ,
321
+ base_rect_size = base_size / 22 ) {
284
322
# Starts with theme_bw and remove most parts
285
- theme_bw(base_size = base_size , base_family = base_family ) %+ replace %
323
+ theme_bw(
324
+ base_size = base_size ,
325
+ base_family = base_family ,
326
+ base_line_size = base_line_size ,
327
+ base_rect_size = base_rect_size
328
+ ) %+ replace %
286
329
theme(
287
330
axis.ticks = element_blank(),
288
331
legend.background = element_blank(),
@@ -298,8 +341,15 @@ theme_minimal <- function(base_size = 11, base_family = "") {
298
341
299
342
# ' @export
300
343
# ' @rdname ggtheme
301
- theme_classic <- function (base_size = 11 , base_family = " " ){
302
- theme_bw(base_size = base_size , base_family = base_family ) %+ replace %
344
+ theme_classic <- function (base_size = 11 , base_family = " " ,
345
+ base_line_size = base_size / 22 ,
346
+ base_rect_size = base_size / 22 ) {
347
+ theme_bw(
348
+ base_size = base_size ,
349
+ base_family = base_family ,
350
+ base_line_size = base_line_size ,
351
+ base_rect_size = base_rect_size
352
+ ) %+ replace %
303
353
theme(
304
354
# no background and no grid
305
355
panel.border = element_blank(),
@@ -322,7 +372,9 @@ theme_classic <- function(base_size = 11, base_family = ""){
322
372
323
373
# ' @export
324
374
# ' @rdname ggtheme
325
- theme_void <- function (base_size = 11 , base_family = " " ) {
375
+ theme_void <- function (base_size = 11 , base_family = " " ,
376
+ base_line_size = base_size / 22 ,
377
+ base_rect_size = base_size / 22 ) {
326
378
theme(
327
379
# Use only inherited elements and make almost everything blank
328
380
# Only keep indispensable text
@@ -347,14 +399,20 @@ theme_void <- function(base_size = 11, base_family = "") {
347
399
348
400
# ' @export
349
401
# ' @rdname ggtheme
350
- theme_test <- function (base_size = 11 , base_family = " " ) {
402
+ theme_test <- function (base_size = 11 , base_family = " " ,
403
+ base_line_size = base_size / 22 ,
404
+ base_rect_size = base_size / 22 ) {
351
405
half_line <- base_size / 2
352
-
406
+
353
407
theme(
354
- line = element_line(colour = " black" , size = 0.5 , linetype = 1 ,
355
- lineend = " butt" ),
356
- rect = element_rect(fill = " white" , colour = " black" ,
357
- size = 0.5 , linetype = 1 ),
408
+ line = element_line(
409
+ colour = " black" , size = base_line_size ,
410
+ linetype = 1 , lineend = " butt"
411
+ ),
412
+ rect = element_rect(
413
+ fill = " white" , colour = " black" ,
414
+ size = base_rect_size , linetype = 1
415
+ ),
358
416
text = element_text(
359
417
family = base_family , face = " plain" ,
360
418
colour = " black" , size = base_size ,
0 commit comments