forestplot
forestplot copied to clipboard
Output gTree object
The forestplot function print the plot directly to the screen and unable to use ggsave function to save the plot. Also work with plot arranging etc. Might be a good idea to add grid.grab() at the end of drawForestplotObject function to return a gTree object.
One of my plans has been to return a gTree-object from the drawForestplotObject function but so far I've settled with the change to a split between the basic function and the plot/print-function. When I save a plot I use png() and similar functions, ggsave is ggplot-specific and also not an S3-function so it would be a little strange to rely on ggplot for this but I guess one could use an S3 for grid.draw and simply use the drawForestplotObject there.
The idea behind this is one of my colleagues asked if she can use arrangeGrob function in the gridExtra package to put multiple plots in one page. I find out grid.grab() can capture the view ports and export the plot as a gTree object, and further to manipulate the gTree object. The ggsave use grid.draw internally to save the plot. Any gTree plot object can be saved with ggsave. Some people just get to used with ggsave I think.
Sorry to ask, but is it possible to add an arrow at the bottom of the x-axis to indicate the treatment direction? Many thanks.
The gTree has been on my "I need to dig into this"-list for a long time. I haven't found any info though on how it works with viewport, the only thing I've found is that it has the ability to group several grobs but I need to be able to nest them - forestplot uses extensively the grid.layout.
Arrow is probably easy to do if you are comfortable selecting viewports and adding to them, there is no automatic for this though. If you add a graphic on what you want to attain I can probably better grasp on how to do it.
Since the forest plot is quite standard. The position of elements are aligned in horizontally with each other, gtable package might be a better choice compared to using viewport. The grid.layout can be a headache.
Here is a easy solution with ggplot2, the gtable package can be used instead of patchwork. I don't like depending on too many packages. The output had an arrow at the bottom.
Unfortunately I don't see how this would work. In 3.0 all the plotting is moved into the final stage allowing a very flexible handling of staged object manipulation etc.