-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathPlaying_with_fonts_and_texts.Rmd
148 lines (116 loc) · 3.93 KB
/
Playing_with_fonts_and_texts.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
title: Playing with fonts and texts
author: Marcin Kosinski
output:
html_document:
mathjax: default
fig_caption: true
toc: true
section_numbering: true
css: ggsci.css
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Playing with fonts and texts}
---
```{r include = FALSE}
library(knitr)
opts_chunk$set(
comment = "",
fig.width = 12,
message = FALSE,
warning = FALSE,
tidy.opts = list(
keep.blank.line = TRUE,
width.cutoff = 150
),
options(width = 150),
eval = TRUE
)
```
```{r}
library("survminer")
```
> This vignette covers changes between versions 0.2.4 and 0.2.5 for additional texts and fonts customization enabled for subtitles and captions.
# Survival plot
## Basic
Compare the basic plot
```{r}
library("survival")
fit<- survfit(Surv(time, status) ~ sex, data = lung)
# Drawing survival curves
ggsurvplot(fit, data = lung)
```
## Customized
with the plot where every possible text on a `plot` is specified
```{r}
ggsurvplot(fit, data = lung,
title = "Survival curves", subtitle = "Based on Kaplan-Meier estimates",
caption = "created with survminer",
font.title = c(16, "bold", "darkblue"),
font.subtitle = c(15, "bold.italic", "purple"),
font.caption = c(14, "plain", "orange"),
font.x = c(14, "bold.italic", "red"),
font.y = c(14, "bold.italic", "darkred"),
font.tickslab = c(12, "plain", "darkgreen"))
```
# Risk table
Now allow `risk.table` to be displayed.
## Basic
Please compare basic plot with a risk table
```{r}
ggsurvplot(fit, data = lung, risk.table = TRUE)
```
## Customized
with the plot where every possible text on a `plot` and `table` is specified
```{r}
ggsurvplot(fit, data = lung,
title = "Survival curves", subtitle = "Based on Kaplan-Meier estimates",
caption = "created with survminer",
font.title = c(16, "bold", "darkblue"),
font.subtitle = c(15, "bold.italic", "purple"),
font.caption = c(14, "plain", "orange"),
font.x = c(14, "bold.italic", "red"),
font.y = c(14, "bold.italic", "darkred"),
font.tickslab = c(12, "plain", "darkgreen"),
########## risk table #########,
risk.table = TRUE,
risk.table.title = "Note the risk set sizes",
risk.table.subtitle = "and remember about censoring.",
risk.table.caption = "source code: website.com",
risk.table.height = 0.45)
```
# ncens plot
Finally, allow `ncens.plot` to be displayed.
## Basic
Please compare basic plot with a risk table and a `ncens` plot
```{r, fig.height = 7.5, fig.width = 6}
ggsurvplot(fit, data = lung, risk.table = TRUE, ncensor.plot = TRUE)
```
## Customized
with the full customization
```{r, fig.height = 7.5, fig.width = 6}
ggsurvplot(fit, data = lung,
title = "Survival curves", subtitle = "Based on Kaplan-Meier estimates",
caption = "created with survminer",
font.title = c(16, "bold", "darkblue"),
font.subtitle = c(15, "bold.italic", "purple"),
font.caption = c(14, "plain", "orange"),
font.x = c(14, "bold.italic", "red"),
font.y = c(14, "bold.italic", "darkred"),
font.tickslab = c(12, "plain", "darkgreen"),
########## risk table #########,
risk.table = TRUE,
risk.table.title = "Note the risk set sizes",
risk.table.subtitle = "and remember about censoring.",
risk.table.caption = "source code: website.com",
risk.table.height = 0.35,
ncensor.plot = TRUE,
ncensor.plot.title = "Number of censorings",
ncensor.plot.subtitle = "over the time.",
ncensor.plot.caption = "data available at data.com",
ncensor.plot.height = 0.35)
```
# Notes
- Note that you will probably need to extend the default risk table height and ncens plot height after those customizations.
- Distinct between `title` and `subtitle` for the `curve_plot` and `risk.table.title` and `risk.table.subtitle` for the `table` / `ncens.plot.title` and `ncens.plot.subtitle` for the `ncens`.
- Fonts are set simultaneously for the `curve_plot`, for the `table` and for the `ncens` parts. This might change in the future.