Skip to content

Commit d07d6ad

Browse files
added table text colour and table text colour oeverwrite and associated argument in ui and server logic
1 parent 079514e commit d07d6ad

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ License: MIT + file LICENSE
5555
SystemRequirements: pandoc with https support
5656
LazyData: true
5757
VignetteBuilder: knitr
58-
RoxygenNote: 7.2.3
58+
RoxygenNote: 7.3.0
5959
Encoding: UTF-8

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# coveffectsplot 1.0.5
2+
* hotfix for upcoming ggplot2
3+
* added option to not color table text
4+
15
# coveffectsplot 1.0.4
26
* updated vignettes and examples
37
* added citation and start up message

R/forest_plot.R

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ label_wrap <- function(width) {
6565
#' @param break_ylabel Split Y axis labels into multiple lines. Logical FALSE TRUE.
6666
#' @param y_label_text_width Number of characters to break Y axis labels.
6767
#' @param table_text_size Table text size.
68+
#' @param table_text_colour_overwrite. Logical TRUE FALSE.
69+
#' @param table_text_colour Table text color to be used and overwrites mapped color
6870
#' @param base_size theme_bw base_size for the plot and table.
6971
#' @param theme_benrich apply Benjamin Rich's theming.
7072
#' @param table_title What text to use for table title (theme_benrich has a default).
@@ -385,6 +387,8 @@ forest_plot <- function(
385387
break_ylabel = FALSE,
386388
y_label_text_width = 25,
387389
table_text_size = 7,
390+
table_text_colour_overwrite = FALSE,
391+
table_text_colour = "none",
388392
base_size = 22,
389393
theme_benrich = FALSE,
390394
table_title = "",
@@ -943,7 +947,7 @@ forest_plot <- function(
943947
if (table_position != "none") {
944948
table_plot <- ggplot2::ggplot(data = data,
945949
ggplot2::aes_string(y = "label"))
946-
if ( !paramname_color) {
950+
if ( !paramname_color && !table_text_colour_overwrite) {
947951
table_plot <- table_plot +
948952
ggplot2::aes_string(group = "paramname") +
949953
ggplot2::geom_text(
@@ -957,7 +961,7 @@ forest_plot <- function(
957961
)
958962
}
959963

960-
if ( paramname_color) {
964+
if ( paramname_color && !table_text_colour_overwrite) {
961965
table_plot <- table_plot +
962966
ggplot2::aes_string(group = "paramname", colour = "paramname") +
963967
ggplot2::geom_text(
@@ -973,7 +977,20 @@ forest_plot <- function(
973977
values = interval_col_values)
974978

975979
}
976-
980+
if ( table_text_colour_overwrite) {
981+
table_plot <- table_plot +
982+
ggplot2::aes_string(group = "paramname") +
983+
ggplot2::geom_text(
984+
ggplot2::aes_string(
985+
x = 1,
986+
label = "LABEL",
987+
hjust = 0.5
988+
),
989+
size = table_text_size, colour = table_text_colour,
990+
position = ggplot2::position_dodge(width = vertical_dodge_height)
991+
)
992+
}
993+
977994
if ( !is.function(facet_labeller)) {
978995
if (facet_labeller != "label_wrap_gen") {
979996
if (table_facet_switch != "none") {

inst/shiny/server.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function(input, output, session) {
229229
paramcols <- paste0("c(", paste0("input$col", 1:ncols, collapse = ", "), ")")
230230
paramcols <- eval(parse(text = paramcols))
231231
}
232-
232+
233233
if(!input$shapebyparamname){
234234
paramshapes <- input$shapepointrange
235235
}
@@ -264,6 +264,8 @@ function(input, output, session) {
264264
break_ylabel = ..(input$breakylabel),
265265
y_label_text_width= ..(input$ylabeltextwidth),
266266
table_text_size = ..(input$tabletextsize),
267+
table_text_colour_overwrite = ..(input$tabletextcoloroverwrite),
268+
table_text_colour = ..(input$tabletextcolour),
267269
base_size = ..(input$base_size),
268270
theme_benrich = ..(input$theme_benrich),
269271
table_title = escape_newline(..(input$custom_table_title)),

inst/shiny/ui.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ fluidPage(
188188
"Table Options",
189189
numericInput("sigdigits",label = "Significant Digits",value = 2,min=0,max=NA),
190190
sliderInput("tabletextsize", "Table Text Size", min=1, max=12,step=0.5, value=7),
191+
checkboxInput('tabletextcoloroverwrite',
192+
'Overwrite Table Text Color?', value = FALSE),
193+
conditionalPanel(condition = "input.tabletextcoloroverwrite" ,
194+
colourpicker::colourInput("tabletextcolour",
195+
"Table Text Color:",
196+
value= "black",
197+
showColour = "both",allowTransparent=TRUE,
198+
returnName = TRUE)),
191199
sliderInput("plottotableratio", "Plot to Table Ratio", min=1, max=5,
192200
value=4,step=0.25,
193201
animate = FALSE),

man/forest_plot.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)