Update to v0.4.9000

This commit is contained in:
gnoblet 2022-12-21 10:48:07 -05:00
parent 5c881dc558
commit cbee42a39e
15 changed files with 191 additions and 176 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
.Rdata .Rdata
.httr-oauth .httr-oauth
.DS_Store .DS_Store
R/test.R

View file

@ -1,7 +1,7 @@
Package: visualizeR Package: visualizeR
Type: Package Type: Package
Title: What a color! What a viz! Title: What a color! What a viz!
Version: 0.3.9000 Version: 0.4.9000
Authors@R: c( Authors@R: c(
person( person(
'Noblet', 'Guillaume', 'Noblet', 'Guillaume',
@ -17,13 +17,12 @@ Depends: R (>= 4.1.0)
License: GPL (>= 3) License: GPL (>= 3)
Encoding: UTF-8 Encoding: UTF-8
LazyData: true LazyData: true
RoxygenNote: 7.2.1 RoxygenNote: 7.2.3
Imports: Imports:
ggplot2, ggplot2,
rlang, rlang,
grDevices, grDevices,
glue, glue,
scales, scales
ggblanket (== 1.6.1)
Suggests: knitr, sf, tmap Suggests: knitr, sf, tmap
VignetteBuilder: knitr VignetteBuilder: knitr

View file

@ -1,9 +1,16 @@
# visualizeR 0.4.9000
* Breaking changes: remove dependency to `ggblanket`.
* Full rewrite of `theme_reach()`.
* `bar_reach` is now `bar()` and theming is passed through argument `theme` for which default is `theme_reach()`.
* `point_reach` is now `point()` and theming is passed through argument `theme` for which default is `theme_reach()`.
# visualizeR 0.3.9000 # visualizeR 0.3.9000
* Breaking changes: update to `ggblanket` v1.6.1. * Breaking changes: update to `ggblanket` v1.6.1.
* Add plotting functions for indicator maps. * Add plotting functions for indicator maps.
# visualizeR 0.2.9000 # visualizeR 0.2.9000
* Breaking changes: almost all functions got refinements, and there are new functions, typically `hbar()` becomes `bar_reach()` and `point_reach()` is added. * Breaking changes: almost all functions got refinements, and there are new functions, typically `hbar()` becomes `bar_reach()` and `point_reach()` is added.

View file

@ -89,20 +89,28 @@ df <- penguins |>
mean_fl = mean(flipper_length_mm, na.rm = T)) |> mean_fl = mean(flipper_length_mm, na.rm = T)) |>
ungroup() ungroup()
# Simple bar chart by group # Simple bar chart by group with some alpha transparency
bar_reach(df, mean_bl, island, species, percent = FALSE, x_title = "Mean of bill length") bar(df, island, mean_bl, species, percent = FALSE, alpha = 0.6, x_title = "Mean of bill length")
``` ```
<img src="man/figures/README-example-bar-chart-1.png" width="100%" /> <img src="man/figures/README-example-bar-chart-1.png" width="100%" />
``` r ``` r
# Using another color palette # Using another color palette through `theme_reach()` and changing scale to percent
bar_reach(df, mean_bl, island, species, percent = FALSE, palette = "artichoke_3", legend_rev = TRUE) bar(df, island,mean_bl, species, percent = TRUE, theme = theme_reach(palette = "artichoke_3"))
``` ```
<img src="man/figures/README-example-bar-chart-2.png" width="100%" /> <img src="man/figures/README-example-bar-chart-2.png" width="100%" />
``` r
# Not flipped, with text added, group_title, no y-axis and no bold for legend
bar(df, island, mean_bl, species, group_title = "Species", flip = FALSE, add_text = TRUE, add_text_suffix = "%", percent = FALSE, theme = theme_reach(text_font_face = "plain", axis_y = FALSE))
```
<img src="man/figures/README-example-bar-chart-3.png" width="100%" />
### Example 2: Point chart, already REACH themed ### Example 2: Point chart, already REACH themed
At this stage, `point_reach()` only supports categorical grouping colors At this stage, `point_reach()` only supports categorical grouping colors
@ -111,7 +119,7 @@ with the `group` arg.
``` r ``` r
# Simple point chart # Simple point chart
point_reach(penguins, bill_length_mm, flipper_length_mm) point(penguins, bill_length_mm, flipper_length_mm)
``` ```
<img src="man/figures/README-example-point-chart-1.png" width="100%" /> <img src="man/figures/README-example-point-chart-1.png" width="100%" />
@ -119,7 +127,7 @@ point_reach(penguins, bill_length_mm, flipper_length_mm)
``` r ``` r
# Point chart with grouping colors, greater dot size, some transparency, reversed color palette # Point chart with grouping colors, greater dot size, some transparency, reversed color palette
point_reach(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, reverse = TRUE) point(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, size = 3, theme = theme_reach(reverse = TRUE))
``` ```
<img src="man/figures/README-example-point-chart-2.png" width="100%" /> <img src="man/figures/README-example-point-chart-2.png" width="100%" />
@ -127,7 +135,7 @@ point_reach(penguins, bill_length_mm, flipper_length_mm, island, alpha = 0.6, si
``` r ``` r
# Using another color palettes # Using another color palettes
point_reach(penguins, bill_length_mm, flipper_length_mm, island, palette = "artichoke_3") point(penguins, bill_length_mm, flipper_length_mm, island, size = 1.5, x_title = "Bill", y_title = "Flipper", title = "Length (mm)", theme = theme_reach(palette = "artichoke_3", text_font_face = , grid_x = T))
``` ```
<img src="man/figures/README-example-point-chart-3.png" width="100%" /> <img src="man/figures/README-example-point-chart-3.png" width="100%" />

67
man/bar.Rd Normal file
View file

@ -0,0 +1,67 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bar.R
\name{bar}
\alias{bar}
\title{Simple bar chart}
\usage{
bar(
df,
x,
y,
group = NULL,
flip = TRUE,
percent = TRUE,
position = "dodge",
alpha = 1,
x_title = NULL,
y_title = NULL,
group_title = NULL,
title = NULL,
subtitle = NULL,
caption = NULL,
add_text = FALSE,
add_text_suffix = "",
theme = theme_reach()
)
}
\arguments{
\item{df}{A data frame.}
\item{x}{A numeric column.}
\item{y}{A character column or coercible as a character column.}
\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.}
\item{flip}{TRUE or FALSE. Default to TRUE or horizontal bar plot.}
\item{percent}{TRUE or FALSE. Should the x-labels (and text labels if present) be displayed as percentages? Default to TRUE.}
\item{position}{Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".}
\item{alpha}{Fill transparency.}
\item{x_title}{The x scale title. Default to NULL.}
\item{y_title}{The y scale title. Default to NULL.}
\item{group_title}{The group legend title. Default to NULL.}
\item{title}{Plot title. Default to NULL.}
\item{subtitle}{Plot subtitle. Default to NULL.}
\item{caption}{Plot caption. Default to NULL.}
\item{add_text}{TRUE or FALSE. Add the value as text.}
\item{add_text_suffix}{If percent is FALSE, should we add a suffix to the text label?}
\item{theme}{Whatever theme. Default to theme_reach().}
}
\value{
A bar chart
}
\description{
Simple bar chart
}

View file

@ -1,82 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bar.R
\name{bar_reach}
\alias{bar_reach}
\title{Simple bar chart}
\usage{
bar_reach(
df,
x,
y,
group = NULL,
percent = TRUE,
palette = "main",
reverse = FALSE,
family = "Leelawadee",
alpha = 1,
width = 0.5,
x_title = NULL,
y_title = NULL,
group_title = NULL,
position = "dodge",
title = NULL,
subtitle = NULL,
caption = NULL,
text_size = 10,
title_size = 14,
legend_position = "right",
legend_rev = TRUE,
...
)
}
\arguments{
\item{df}{A data frame.}
\item{x}{A numeric column.}
\item{y}{A character column or coercible as a character column.}
\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.}
\item{percent}{TRUE or FALSE. Should the x-labels be displayed as percentages? Default to TRUE.}
\item{palette}{Palette name from 'pal_reach()'.}
\item{reverse}{Boolean indicating whether the palette should be reversed.}
\item{family}{The font family for all plot's texts. Default to "Leelawadee".}
\item{alpha}{Transparency.}
\item{width}{Width.}
\item{x_title}{The x scale title. Default to NULL.}
\item{y_title}{The y scale title. Default to NULL.}
\item{group_title}{The group legend title. Default to NULL.}
\item{position}{Should the chart be stacked? Default to "dodge". Can take "dodge" and "stack".}
\item{title}{Plot title. Default to NULL.}
\item{subtitle}{Plot subtitle. Default to NULL.}
\item{caption}{Caption title string. Default to NULL.}
\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.}
\item{title_size}{The size of the title text. Defaults to 14.}
\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".}
\item{legend_rev}{Reverse the color in the guide? Default to TRUE.}
\item{...}{Other arguments to be passed to "ggblanket::gg_col"}
}
\value{
A bar chart
}
\description{
`ggblanket` as internals for deciding whether the bar chart is horizontally readable.
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 145 KiB

58
man/point.Rd Normal file
View file

@ -0,0 +1,58 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/point.R
\name{point}
\alias{point}
\title{Simple bar chart}
\usage{
point(
df,
x,
y,
group = NULL,
flip = TRUE,
alpha = 1,
size = 1,
x_title = NULL,
y_title = NULL,
group_title = NULL,
title = NULL,
subtitle = NULL,
caption = NULL,
theme = theme_reach()
)
}
\arguments{
\item{df}{A data frame.}
\item{x}{A numeric column.}
\item{y}{A character column or coercible as a character column.}
\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.}
\item{flip}{TRUE or FALSE. Default to TRUE or horizontal bar plot.}
\item{alpha}{Fill transparency.}
\item{size}{Point size.}
\item{x_title}{The x scale title. Default to NULL.}
\item{y_title}{The y scale title. Default to NULL.}
\item{group_title}{The group legend title. Default to NULL.}
\item{title}{Plot title. Default to NULL.}
\item{subtitle}{Plot subtitle. Default to NULL.}
\item{caption}{Plot caption. Default to NULL.}
\item{theme}{Whatever theme. Default to theme_reach().}
}
\value{
A bar chart
}
\description{
Simple bar chart
}

View file

@ -1,73 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/point.R
\name{point_reach}
\alias{point_reach}
\title{Simple point chart}
\usage{
point_reach(
df,
x,
y,
group = NULL,
palette = "main",
reverse = FALSE,
family = "Leelawadee",
alpha = 1,
size = 1.5,
x_title = NULL,
y_title = NULL,
group_title = NULL,
title = NULL,
subtitle = NULL,
caption = NULL,
text_size = 10,
title_size = 14,
legend_position = "right",
...
)
}
\arguments{
\item{df}{A data frame.}
\item{x}{A numeric column.}
\item{y}{A character column or coercible as a character column.}
\item{group}{Some grouping categorical column, e.g. administrative areas or population groups.}
\item{palette}{Palette name from 'pal_reach()'.}
\item{reverse}{Boolean indicating whether the palette should be reversed.}
\item{family}{The font family for all plot's texts. Default to "Leelawadee".}
\item{alpha}{Transparency.}
\item{size}{Dot size. Default to 1.5.}
\item{x_title}{The x scale title. Default to NULL.}
\item{y_title}{The y scale title. Default to NULL.}
\item{group_title}{The group legend title. Default to NULL.}
\item{title}{Plot title. Default to NULL.}
\item{subtitle}{Plot subtitle. Default to NULL.}
\item{caption}{Caption title string. Default to NULL.}
\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.}
\item{title_size}{The size of the title text. Defaults to 14.}
\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".}
\item{...}{Other arguments to be passed to "ggblanket::gg_col"}
}
\value{
A bar chart
}
\description{
`ggblanket` as internals for deciding whether the bar chart is horizontally readable.
}

View file

@ -8,14 +8,24 @@ theme_reach(
palette = "main", palette = "main",
discrete = TRUE, discrete = TRUE,
reverse = FALSE, reverse = FALSE,
family = "Leelawadee", font_family = "Leelawadee",
title_size = 12,
title_color = cols_reach("main_grey"),
title_font_face = "bold",
text_size = 10, text_size = 10,
title_size = 14, text_color = cols_reach("main_grey"),
plot_background_pal = "#FFFFFF", text_font_face = "bold",
panel_background_pal = "#FFFFFF", panel_background_color = "#FFFFFF",
legend_position = "right", legend_position = "right",
legend_direction = "vertical", legend_direction = "vertical",
legend_reverse = TRUE, legend_reverse = TRUE,
axis_x = TRUE,
axis_y = TRUE,
grid_x = FALSE,
grid_y = FALSE,
grid_color = cols_reach("main_lt_grey"),
grid_x_size = 0.1,
grid_y_size = 0.1,
... ...
) )
} }
@ -26,15 +36,21 @@ theme_reach(
\item{reverse}{Boolean indicating whether the palette should be reversed.} \item{reverse}{Boolean indicating whether the palette should be reversed.}
\item{family}{The font family for all plot's texts. Default to "Leelawadee".} \item{font_family}{The font family for all plot's texts. Default to "Leelawadee".}
\item{title_size}{The size of the title. Defaults to 12.}
\item{title_color}{Title color.}
\item{title_font_face}{Title font face. Default to "bold". Font face ("plain", "italic", "bold", "bold.italic").}
\item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.} \item{text_size}{The size of all text other than the title, subtitle and caption. Defaults to 10.}
\item{title_size}{The size of the title text_family. Defaults to 14.} \item{text_color}{Text color.}
\item{plot_background_pal}{The color for the plot background color. Default to white.} \item{text_font_face}{Text font face. Default to "bold". Font face ("plain", "italic", "bold", "bold.italic").}
\item{panel_background_pal}{The color for the panel background color. Default to white.} \item{panel_background_color}{The color for the panel background color. Default to white.}
\item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".} \item{legend_position}{Position of the legend; Default to "right". Can take "right", "left", "top", "bottom" or "none".}
@ -42,7 +58,21 @@ theme_reach(
\item{legend_reverse}{Reverse the color in the guide? Default to TRUE.} \item{legend_reverse}{Reverse the color in the guide? Default to TRUE.}
\item{...}{Additional arguments passed to `ggblanket::gg_theme()`.} \item{axis_x}{Boolean. Do you need x-axis?}
\item{axis_y}{Boolean. Do you need y-axis?}
\item{grid_x}{Boolean. Do you need major grid lines for x-axis?}
\item{grid_y}{Boolean. Do you need major grid lines for y-axis?}
\item{grid_color}{Grid lines color.}
\item{grid_x_size}{X line size.}
\item{grid_y_size}{Y line size.}
\item{...}{Additional arguments passed to `ggplot2::gg_theme()`.}
} }
\value{ \value{
The base REACH theme The base REACH theme