gforge / forestplot

Advanced forest plots in R using grid graphics
44 stars 15 forks source link

Feature request: improve customization with gpar #32

Closed MetaEntropy closed 4 years ago

MetaEntropy commented 4 years ago

Current feature and limitation

The col parameter of the forestplot function can be set to a fpColors object to customize colors of most non-text graphical elements of a forestplot. forestplot has a few additionnal parameters such as lwd.ci and lty.ci. It does not allow full customization. For instance, linejoin and lineend cannot be customized for ci and summary elements without overriding fn.ci_norm and fn.ci_sum. To follow the style of forest plots of the Journal of American Medical Association (JAMA), I had to customize these two functions in order to set mitre/square linejoin/lineend and choose different border and fill colors for diamonds.

Proposal

Provide a shapes_gp describing the same elements as col but with gpar() elements (like txt_gp) rather than just colors. Together, shapes_gp and txt_gp should allow full customization of all graphical elements. When a parameter (e.g. line type of CI) is both defined in shapes_gp and in the legacy parameter, shapes_gp should take the precedence. Indeed, some of these legacy parameters have default values, and giving them precedence would make customization counter-intuitive since overriding shapes_gp would not be enough. The interfaces of fpDrawNormalCI, fpDrawSummaryCI, fpDrawCircleCI should be kept compatible (keeping lwd, lty parameters) but the additionnal shapes_gp parameter would be taken as parameter and used by these functions.

Pull request

I am working on a pull request

gforge commented 4 years ago

Sounds like a great idea.

gforge commented 4 years ago

Awesome! All the updates are now in the develop-branch. Checking CRAN-compatibilty and will send update tomorrow.

If you have the time an update to the vignette would be nice. The example shows the concept, the vignette in turn is a little more inspirational of how to do proper plots, e.g. you could show your JAMA layout as a reference.