Description Usage Arguments Value See Also Examples
This function allows you to add text to a swimmers plot created with swimmer_plot
1 2 3 4 5 6 7 8 9 10 11 12 13 |
df_text |
a data frame |
id |
column name for id, default is 'id' |
start |
column name with the text start locations (if there is no start column will default 0 for all text) |
label |
a column with the text to be added to the plot |
name_col |
a column name to map the text colour |
name_size |
a column name to map the text size |
name_alpha |
a column name to map the text transparency |
name_fontface |
a column name to map the text fontface ("plain", "bold", "italic", "bold.italic" can all be used) |
adj.y |
amount to adjust the text within the box vertically (default is 0, text is in the centre of each bar) |
adj.x |
amount to adjust the text within the box horizontally (default is 0, text starts at the origin) |
... |
additional geom_text() arguments |
a swimmer plot with text on the bars
swimmer_plot
swimmer_points
swimmer_lines
swimmer_points_from_lines
swimmer_arrows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #Start with a base swimmer plot
swim_plot <-
swimmer_plot(df=ClinicalTrial.Arm,id='id',end='End_trt',
name_fill='Arm',col="black",id_order='Arm',alpha=0.6)
# Then add text to the plot
swim_plot_with_text <- swim_plot + swimmer_text(df_text =
ClinicalTrial.Stage,label = 'Stage',size=3,
fontface=ifelse(ClinicalTrial.Stage$Stage=="Early Stage","bold","plain"))
# Add ggplot layers to improve the plot's aesthetic
swim_plot_with_text +
ggplot2::scale_fill_manual(name="Treatment",values=c("#e41a1c", "#377eb8","#4daf4a"))+
ggplot2::ylab('Time (Days)')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.