adayim / forestploter

Draw forestplot in R
Other
79 stars 10 forks source link

difference color for point estimate and confidence interval #22

Closed bioljlin closed 1 year ago

bioljlin commented 2 years ago

Hi there! I was wandering if it is possible to define difference colors for point estimates and confidence intervals (like blue for point estimate and black for confidence interval)?

adayim commented 2 years ago

Yes, you can. Please check the vignette here. Use edit_plot to change it. And there's already a same issue here #20 , search it before you ask.

g <- edit_plot(g,
               row = c(3, 6, 11, 13),
               col = 4,
               which = "ci",
               gp = gpar(col = "green"))
bioljlin commented 2 years ago

Thanks for your reply. It seems to change the color of both confidence of interval and point estimate. I would like to show difference color for point estimate, as shown in the screen shot below(black color for the line of confidence interval and blue color for the box of point estimate).

BF7F9CA1-DCFB-49C6-BB83-914A86D679A4

adayim commented 2 years ago

Thank you for reporting this, you can change the color by setting ci_fill in the forest_theme function. Please let me know if the changes works for you. And try to edit the plot see if the changes working. Thank you.

gpessoaamorim commented 2 years ago

This is really helpful. One other feature that would be of great value would be to present CIs on top of the boxes for groups where the CI is smaller than the box (and with a different colour) as is standard practice now

gpessoaamorim commented 2 years ago

This works well but is not transferring to the legend (see snippet)

image

adayim commented 2 years ago

Hi, thank you for reporting this issue. I did some updates and it should be fixed. Can you install it from GitHub and try it again?

Also, you should be able to change the transparency of the point estimation now. Do you think this method can solve your previous question?

gpessoaamorim commented 2 years ago

Thanks for looking into this. I've installed the dev version but still not working

This is what my code looks like:

forest_plot_mortality<-forest(
  forest_plot_table[,c(1:7,11:13)],

        est=list(
        forest_plot_table$`Mortality (RECOVERY crude)`,
         forest_plot_table$`Mortality (RECOVERY adjusted)`,
         forest_plot_table$`Mortality (Reference population)`
),

lower=list(forest_plot_table$`lower_bound_95CI_RECOVERY (crude)`,
           forest_plot_table$`lower_bound_95CI_RECOVERY (adjusted)`,
           forest_plot_table$`lower_bound_95CI_Reference population`
),

upper=list(forest_plot_table$`upper_bound_95CI_RECOVERY (crude)`,
           forest_plot_table$`upper_bound_95CI_RECOVERY (adjusted)`,
           forest_plot_table$`upper_bound_95CI_Reference population`
),

sizes=list(1/forest_plot_table$`Variance (RECOVERY crude)`/10,
           1/forest_plot_table$`Variance (RECOVERY adjusted)`/10,
           1/forest_plot_table$`Variance (Reference population)`/10),

ci_column = 7,
xlim=c(0,35),
xlab = "Mortality (%)",
ref_line = 0,
nudge_y=0.3,
theme = forest_theme(
  ci_col="black",
                    ci_fill =colors,
                     ci_alpha=0.9,
                     legend_name="Cohort",
                     ci_pch=15,
                     ci_Theight = 0.2,
                     legend_position="bottom",
                     base_family = "Mulish",
                     legend_value=c("RECOVERY (crude)",
                                    "RECOVERY (adjusted)",
                                    "Reference population")))%>%
  insert_text(.,
              text = "Mortality (95% CI)",
              col = 8:10,
              part = "header",
              gp = gpar(fontface = "bold"))%>%
  edit_plot(row=10,
            which="text",
            gp=gpar(fontface="bold"
                    ))
adayim commented 2 years ago

Hi there, I think I know what's happening here. You need to use pch = 22 as legendGrob only supports fill color when pch = 21:25.

gpessoaamorim commented 2 years ago

Thanks – that absolutely solved the issue!

From: Alim Dayim @.> Sent: 10 November 2022 13:47 To: adayim/forestploter @.> Cc: Guilherme Pessoa-Amorim @.>; Comment @.> Subject: Re: [adayim/forestploter] difference color for point estimate and confidence interval (Issue #22)

Hi there, I think I know what's happening here. You need to use pch = 22 as legendGrob only supports fill color when pch = 21:25.

— Reply to this email directly, view it on GitHubhttps://github.com/adayim/forestploter/issues/22#issuecomment-1310305035, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOIBNARAZT6AEVQWP7XHE5LWHT4EHANCNFSM6AAAAAAQ5GJ5JI. You are receiving this because you commented.Message ID: @.***>