adayim / consort

Create CONSORT diagrams for clinical studies.
Other
28 stars 4 forks source link

Title and Footnote options #19

Open AndrewNute opened 5 months ago

AndrewNute commented 5 months ago

This idea is for an enhancement.

I am trying unsuccessfully to add some footnote information into the plot that will explain how I arrived at the number in the first box. I have tried converting the plot to a grob for use in cowplot as well as other hack-like maneuvers involving ggplot.

Although it would be great if there was some in package function for converting to ggplot or a grid object, an easier fix might be to add a title option and a footnote box option. That way, the figure can be presented as a standalone diagram without the need for an external captions to accompany it.

Another alternative could be more formatting options for label boxes but those are obviously not intended for deeper contextual information.

Cheers!

adayim commented 5 months ago

Hi,

Assuming object g is your consort diagram. Use the code below to create title and footnote.

library(patchwork)

wrap_elements(build_grid(g)) + plot_annotation(
  title = 'Consort diagram',
  subtitle = 'Flow chart of the XX study',
  caption = 'Disclaimer: None of these plots are insightful'
)

Function build_grid will convert plot to grid object and use patchwork to assemble plot.