Added text sizes as params

This commit is contained in:
gnoblet 2022-07-10 19:00:39 -04:00
parent d349e6a6d3
commit bdee722ce1
7 changed files with 65 additions and 11 deletions

View file

@ -6,21 +6,24 @@
#' @param group Some grouping categorical column, e.g. administrative areas #' @param group Some grouping categorical column, e.g. administrative areas
#' @param initiative Either "reach" or "agora" or "impact" for the color palette #' @param initiative Either "reach" or "agora" or "impact" for the color palette
#' @param pal The color palette from the initiative #' @param pal The color palette from the initiative
#' @param width Width. #' @param width Width
#' @param x_title The x scale title. Default to empty string #' @param x_title The x scale title. Default to empty string
#' @param y_title The y scale title. Default to empty string #' @param y_title The y scale title. Default to empty string
#' @param group_title The group legend title. Defaut to NULL #' @param group_title The group legend title. Defaut to NULL
#' @param font_family The font family. Default to "Leelawadee" #' @param font_family The font family. Default to "Leelawadee"
#' @param font_size Body font size; default to 12
#' @param position Should the chart be stacked? Default to dodge #' @param position Should the chart be stacked? Default to dodge
#' @param reverse Boolean indicating whether the color palette should be reversed #' @param reverse Boolean indicating whether the color palette should be reversed
#' @param title Plot title. Default to empty string #' @param title Plot title. Default to empty string
#' @param subtitle Plot subtitle. Default to empty string #' @param subtitle Plot subtitle. Default to empty string
#' @param title_font_size Default to 16
#' @param subtitle_font_size Default to 14
#' @param ... Other arguments to be passed to "ggblanket::gg_col" #' @param ... Other arguments to be passed to "ggblanket::gg_col"
#' #'
#' @return A horizontal bar chart #' @return A horizontal bar chart
#' #'
#' @export #' @export
hbar <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "primary", width = 0.5, x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", position = "dodge", reverse = FALSE, title = "", subtitle = "", ...){ hbar <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "primary", width = 0.5, x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", font_size = 12, position = "dodge", reverse = FALSE, title = "", subtitle = "", title_font_size = 16, subtitle_font_size = 14, ...){
if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'")) if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'"))
@ -81,21 +84,24 @@ hbar <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "primary"
#' @param group Some grouping categorical column, e.g. administrative areas #' @param group Some grouping categorical column, e.g. administrative areas
#' @param initiative Either "reach" or "agora" or "impact" for the color palette #' @param initiative Either "reach" or "agora" or "impact" for the color palette
#' @param pal The color palette from the initiative #' @param pal The color palette from the initiative
#' @param width Width. #' @param width Width
#' @param x_title The x scale title. Default to empty string #' @param x_title The x scale title. Default to empty string
#' @param y_title The y scale title. Default to empty string #' @param y_title The y scale title. Default to empty string
#' @param group_title The group legend title. Defaut to NULL #' @param group_title The group legend title. Defaut to NULL
#' @param font_family The font family. Default to "Leelawadee" #' @param font_family The font family. Default to "Leelawadee"
#' @param font_size Body font size; default to 12
#' @param position Should the chart be stacked? Default to dodge #' @param position Should the chart be stacked? Default to dodge
#' @param reverse Boolean indicating whether the color palette should be reversed #' @param reverse Boolean indicating whether the color palette should be reversed
#' @param title Plot title. Default to empty string #' @param title Plot title. Default to empty string
#' @param subtitle Plot subtitle. Default to empty string #' @param subtitle Plot subtitle. Default to empty string
#' @param title_font_size Default to 16
#' @param subtitle_font_size Default to 14
#' @param ... Other arguments to be passed to "ggblanket::gg_col" #' @param ... Other arguments to be passed to "ggblanket::gg_col"
#' #'
#' @return A horizontal bar chart #' @return A horizontal bar chart
#' #'
#' @export #' @export
hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "primary", width = 0.5, x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", position = "dodge", reverse = FALSE, title = "", subtitle = "", ...){ hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "primary", width = 0.5, x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", font_size = 12, position = "dodge", reverse = FALSE, title = "", subtitle = "", title_font_size = 16, subtitle_font_size = 14, ...){
if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'")) if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'"))
@ -129,7 +135,7 @@ hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", pal = "
ggblanket::gg_col(x = {{ x }}, ggblanket::gg_col(x = {{ x }},
y = {{ y }}, y = {{ y }},
col = {{ group }}, col = {{ group }},
theme = ggblanket::gg_theme(font = font_family, pal_title = main_col), theme = ggblanket::gg_theme(font = font_family, pal_title = main_col, size_body = font_size, size_title = title_font_size, size_subtitle = subtitle_font_size),
x_title = x_title, x_title = x_title,
y_title = y_title, y_title = y_title,
col_title = group_title, col_title = group_title,

View file

@ -2,7 +2,7 @@ pandoc: 2.14.0.3
pkgdown: 2.0.5 pkgdown: 2.0.5
pkgdown_sha: ~ pkgdown_sha: ~
articles: {} articles: {}
last_built: 2022-07-10T15:26Z last_built: 2022-07-10T22:59Z
urls: urls:
reference: https://gnoblet.github.io/visualizeR/reference reference: https://gnoblet.github.io/visualizeR/reference
article: https://gnoblet.github.io/visualizeR/articles article: https://gnoblet.github.io/visualizeR/articles

View file

@ -63,10 +63,13 @@
<span> y_title <span class="op">=</span> <span class="st">""</span>,</span> <span> y_title <span class="op">=</span> <span class="st">""</span>,</span>
<span> group_title <span class="op">=</span> <span class="cn">NULL</span>,</span> <span> group_title <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> font_family <span class="op">=</span> <span class="st">"Leelawadee"</span>,</span> <span> font_family <span class="op">=</span> <span class="st">"Leelawadee"</span>,</span>
<span> font_size <span class="op">=</span> <span class="fl">12</span>,</span>
<span> position <span class="op">=</span> <span class="st">"dodge"</span>,</span> <span> position <span class="op">=</span> <span class="st">"dodge"</span>,</span>
<span> reverse <span class="op">=</span> <span class="cn">FALSE</span>,</span> <span> reverse <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span> title <span class="op">=</span> <span class="st">""</span>,</span> <span> title <span class="op">=</span> <span class="st">""</span>,</span>
<span> subtitle <span class="op">=</span> <span class="st">""</span>,</span> <span> subtitle <span class="op">=</span> <span class="st">""</span>,</span>
<span> title_font_size <span class="op">=</span> <span class="fl">16</span>,</span>
<span> subtitle_font_size <span class="op">=</span> <span class="fl">14</span>,</span>
<span> <span class="va">...</span></span> <span> <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div> <span><span class="op">)</span></span></code></pre></div>
</div> </div>
@ -98,7 +101,7 @@
<dt>width</dt> <dt>width</dt>
<dd><p>Width.</p></dd> <dd><p>Width</p></dd>
<dt>x_title</dt> <dt>x_title</dt>
@ -117,6 +120,10 @@
<dd><p>The font family. Default to "Leelawadee"</p></dd> <dd><p>The font family. Default to "Leelawadee"</p></dd>
<dt>font_size</dt>
<dd><p>Body font size; default to 12</p></dd>
<dt>position</dt> <dt>position</dt>
<dd><p>Should the chart be stacked? Default to dodge</p></dd> <dd><p>Should the chart be stacked? Default to dodge</p></dd>
@ -133,6 +140,14 @@
<dd><p>Plot subtitle. Default to empty string</p></dd> <dd><p>Plot subtitle. Default to empty string</p></dd>
<dt>title_font_size</dt>
<dd><p>Default to 16</p></dd>
<dt>subtitle_font_size</dt>
<dd><p>Default to 14</p></dd>
<dt>...</dt> <dt>...</dt>
<dd><p>Other arguments to be passed to "ggblanket::gg_col"</p></dd> <dd><p>Other arguments to be passed to "ggblanket::gg_col"</p></dd>

View file

@ -63,10 +63,13 @@
<span> y_title <span class="op">=</span> <span class="st">""</span>,</span> <span> y_title <span class="op">=</span> <span class="st">""</span>,</span>
<span> group_title <span class="op">=</span> <span class="cn">NULL</span>,</span> <span> group_title <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> font_family <span class="op">=</span> <span class="st">"Leelawadee"</span>,</span> <span> font_family <span class="op">=</span> <span class="st">"Leelawadee"</span>,</span>
<span> font_size <span class="op">=</span> <span class="fl">12</span>,</span>
<span> position <span class="op">=</span> <span class="st">"dodge"</span>,</span> <span> position <span class="op">=</span> <span class="st">"dodge"</span>,</span>
<span> reverse <span class="op">=</span> <span class="cn">FALSE</span>,</span> <span> reverse <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span> title <span class="op">=</span> <span class="st">""</span>,</span> <span> title <span class="op">=</span> <span class="st">""</span>,</span>
<span> subtitle <span class="op">=</span> <span class="st">""</span>,</span> <span> subtitle <span class="op">=</span> <span class="st">""</span>,</span>
<span> title_font_size <span class="op">=</span> <span class="fl">16</span>,</span>
<span> subtitle_font_size <span class="op">=</span> <span class="fl">14</span>,</span>
<span> <span class="va">...</span></span> <span> <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div> <span><span class="op">)</span></span></code></pre></div>
</div> </div>
@ -98,7 +101,7 @@
<dt>width</dt> <dt>width</dt>
<dd><p>Width.</p></dd> <dd><p>Width</p></dd>
<dt>x_title</dt> <dt>x_title</dt>
@ -117,6 +120,10 @@
<dd><p>The font family. Default to "Leelawadee"</p></dd> <dd><p>The font family. Default to "Leelawadee"</p></dd>
<dt>font_size</dt>
<dd><p>Body font size; default to 12</p></dd>
<dt>position</dt> <dt>position</dt>
<dd><p>Should the chart be stacked? Default to dodge</p></dd> <dd><p>Should the chart be stacked? Default to dodge</p></dd>
@ -133,6 +140,14 @@
<dd><p>Plot subtitle. Default to empty string</p></dd> <dd><p>Plot subtitle. Default to empty string</p></dd>
<dt>title_font_size</dt>
<dd><p>Default to 16</p></dd>
<dt>subtitle_font_size</dt>
<dd><p>Default to 14</p></dd>
<dt>...</dt> <dt>...</dt>
<dd><p>Other arguments to be passed to "ggblanket::gg_col"</p></dd> <dd><p>Other arguments to be passed to "ggblanket::gg_col"</p></dd>

File diff suppressed because one or more lines are too long

View file

@ -16,10 +16,13 @@ hbar(
y_title = "", y_title = "",
group_title = NULL, group_title = NULL,
font_family = "Leelawadee", font_family = "Leelawadee",
font_size = 12,
position = "dodge", position = "dodge",
reverse = FALSE, reverse = FALSE,
title = "", title = "",
subtitle = "", subtitle = "",
title_font_size = 16,
subtitle_font_size = 14,
... ...
) )
} }
@ -36,7 +39,7 @@ hbar(
\item{pal}{The color palette from the initiative} \item{pal}{The color palette from the initiative}
\item{width}{Width.} \item{width}{Width}
\item{x_title}{The x scale title. Default to empty string} \item{x_title}{The x scale title. Default to empty string}
@ -46,6 +49,8 @@ hbar(
\item{font_family}{The font family. Default to "Leelawadee"} \item{font_family}{The font family. Default to "Leelawadee"}
\item{font_size}{Body font size; default to 12}
\item{position}{Should the chart be stacked? Default to dodge} \item{position}{Should the chart be stacked? Default to dodge}
\item{reverse}{Boolean indicating whether the color palette should be reversed} \item{reverse}{Boolean indicating whether the color palette should be reversed}
@ -54,6 +59,10 @@ hbar(
\item{subtitle}{Plot subtitle. Default to empty string} \item{subtitle}{Plot subtitle. Default to empty string}
\item{title_font_size}{Default to 16}
\item{subtitle_font_size}{Default to 14}
\item{...}{Other arguments to be passed to "ggblanket::gg_col"} \item{...}{Other arguments to be passed to "ggblanket::gg_col"}
} }
\value{ \value{

View file

@ -16,10 +16,13 @@ hbar_percent(
y_title = "", y_title = "",
group_title = NULL, group_title = NULL,
font_family = "Leelawadee", font_family = "Leelawadee",
font_size = 12,
position = "dodge", position = "dodge",
reverse = FALSE, reverse = FALSE,
title = "", title = "",
subtitle = "", subtitle = "",
title_font_size = 16,
subtitle_font_size = 14,
... ...
) )
} }
@ -36,7 +39,7 @@ hbar_percent(
\item{pal}{The color palette from the initiative} \item{pal}{The color palette from the initiative}
\item{width}{Width.} \item{width}{Width}
\item{x_title}{The x scale title. Default to empty string} \item{x_title}{The x scale title. Default to empty string}
@ -46,6 +49,8 @@ hbar_percent(
\item{font_family}{The font family. Default to "Leelawadee"} \item{font_family}{The font family. Default to "Leelawadee"}
\item{font_size}{Body font size; default to 12}
\item{position}{Should the chart be stacked? Default to dodge} \item{position}{Should the chart be stacked? Default to dodge}
\item{reverse}{Boolean indicating whether the color palette should be reversed} \item{reverse}{Boolean indicating whether the color palette should be reversed}
@ -54,6 +59,10 @@ hbar_percent(
\item{subtitle}{Plot subtitle. Default to empty string} \item{subtitle}{Plot subtitle. Default to empty string}
\item{title_font_size}{Default to 16}
\item{subtitle_font_size}{Default to 14}
\item{...}{Other arguments to be passed to "ggblanket::gg_col"} \item{...}{Other arguments to be passed to "ggblanket::gg_col"}
} }
\value{ \value{