Closed Kexin-xu-01 closed 1 year ago
I don't know what you mean by misaligned. You didn't provide any reproducable data to show me. I used the package data and it worked perfectly fine.
dt <- read.csv(system.file("extdata", "example_data.csv", package = "forestploter"))
dt$` ` <- paste(rep(" ", 20), collapse = " ")
dt <- dt[1:10, ]
tm <- forest_theme(base_size = 10,
refline_col = "red",
legend_name = "5 groups",
legend_value = c(1:5)) # I want to plot 5 groups
p <- forest(dt[,c(1, 19)],
est = list(dt$est_gp1,
dt$est_gp2,
dt$est_gp3,
dt$est_gp4,
dt$est),
lower = list(dt$low_gp1,
dt$low_gp2,
dt$low_gp3,
dt$low_gp4,
dt$low),
upper = list(dt$hi_gp1,
dt$hi_gp2,
dt$hi_gp3,
dt$hi_gp4,
dt$hi),
ci_column = 2,
ref_line = 1,
theme = tm)
p
And where do you want to have p-values as asterisks? Would you please state your problem clearly?
Hello! Thank you very much for your very kind answer! I have solved the alignment issue. I would like the pvalue to be added as asterisks to the right of each CI plot (i.e. as , , ). Do you think that would be possible?
Thank you!
Right of CI plot? You mean right hand side of the CI plot? NO, but you can add a new column at the right-hand side and use asterisks as content of the column.
Thank you! Is it possible to have 5 asterisks per row, corresponding to the 5 different groups? How should I specify this in the code? Thank you again!
Yes, you can use line break between asterisks.
Thank you! I have another question. Do you know how to adjust the width of each column? In the first column, some of my texts are too long so they are hidden. I noticed a similar issue in the example plot too. Thank you! ![Uploading Screenshot 2023-01-31 at 22.03.19.png…]()
Sorry, I can't see your screen shot. The width of the column is determined by the text in the table. I think this was already written in the readme and vignettes. You can also use line break.
Sorry, I have reattached the image. As you can see, sometimes the column width is smaller than text, resulting in some of the text being cut off.
I have tried the linebreak, but this makes the row twice as thick as other row. Since I have 5 groups of CI, the row is already very thick. Is there a way to shrink the row thickness for the rows that don't have any CI plot (i.e.. the subheading rows)?
I am very sorry for all these questions.
Leave that row blank and use add_text()
to add the long text.
Hello! Sorry for keeping bothering you! I tried add_text, but because the column width didn't increase, the text occupied some of the neighbouring column too and started overlapping with neighbouring text. Is there a way to increase the column width manually?
I think I know what happened to the plot you pasted from the README. Width of the column is calculated at the beginning. The plot was edited later to have a bold text, and this changed the width of the text. Bold text is wider. I have added an option clip
, but default is to turn off the clip.
Would you mind trying to install the package from GitHub and let me know if it works? It should work, but do let me know.
Thank you very much for your kind edits!
With clip = FALSE, the words are showing but they are overlapping with the following column, since the column width didn't increase.
With clip = TRUE, the end of the words were cut off like before
As I have explained before, the width of the text will be increased if you bold text later. The width will not calculated again. I would suggest you add some space after the longest text so you will have extra space. Use paste
to add some blank space to the text for example.
It worked! Thank you so much for your kind help!
Hello!
I would like to plot multiple CIs on top of each other in the same cell (i.e. same column), represented by different colours & shown in legends.
I am currently aiming for 5 CIs, so I wrote something like this: tm <- forest_theme(base_size = 10, refline_col = "red", legend_name = "5 groups", legend_value = c(1:5)) # I want to plot 5 groups
p <- forest(dt[,c(2,22)], est = list(dt$est_gp1, dt$est_gp2, dt$est_gp3, dt$est_gp4, dt$est_gp5), lower = list(dt$low_gp1, dt$low_gp2, dt$low_gp3, dt$low_gp4, dt$low_gp5), upper = list(dt$hi_gp1, dt$hi_gp2, dt$hi_gp3, dt$hi_gp4, dt$hi_gp5), ci_column = c(3), # because I want them all in the same column ref_line = 1, theme = tm)
However, there was a bug which made some CIs misaligned with the rows (see picture: from "hypertension" in row 6). I have double-checked and I can confirm that the dataframe used for plotting is correctly aligned.
Also, do you know how to add p-values as asterisks to the plot please?
I am trying to make a plot like this.
Thanks!