@@ -302,6 +302,42 @@ make_newdata=function(data,vars,conts=NULL) {
302302}
303303
304304
305+ # ' A Custom ggplot2 Theme for Survival Plots
306+ # '
307+ # ' This theme is designed for use with survival analysis plots, particularly
308+ # ' those created using the `survHE` package. It builds on `theme_bw()` and
309+ # ' customizes axis text, titles, plot background, and legend styling.
310+ # '
311+ # ' Note: To position the legend inside the plot, use an additional call to
312+ # ' `theme(legend.position = c(x, y), legend.justification = c("left", "top"))`.
313+ # '
314+ # ' @return A ggplot2 theme object that can be added to a ggplot.
315+ # ' @examples
316+ # ' library(ggplot2)
317+ # ' library(survHE)
318+ # ' ggplot(mtcars, aes(wt, mpg)) +
319+ # ' geom_point() +
320+ # ' theme_survHE() +
321+ # ' theme(legend.position = c(0.6, 0.8), legend.justification = c("left", "top"))
322+ # ' @export
323+ theme_survHE <- function () {
324+ theme_bw() +
325+ theme(
326+ axis.text.x = element_text(color = " black" , size = 12 ),
327+ axis.text.y = element_text(color = " black" , size = 12 ),
328+ axis.title.x = element_text(color = " black" , size = 14 ),
329+ axis.title.y = element_text(color = " black" , size = 14 ),
330+ axis.line = element_line(colour = " black" ),
331+ panel.background = element_blank(),
332+ panel.border = element_blank(),
333+ plot.title = element_text(size = 18 , face = " bold" ),
334+ legend.position = " none" , # Default to off; override as needed
335+ legend.background = element_blank(),
336+ legend.title = element_text(size = 15 , face = " bold" ),
337+ legend.text = element_text(colour = " black" , size = 14 , face = " plain" )
338+ )
339+ }
340+
305341
306342# ' Make the dataset to be used by \code{ggplot2} to plot the survival curves
307343# '
0 commit comments