Skip to content

Commit

Permalink
Minor fix to border_col argument and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Jenkins committed May 15, 2024
1 parent 55a6e81 commit 4c33aa4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions R/func_pie_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ add_pie_charts <- function(df, admix_columns, lat_column, lon_column, pie_colour
cols = pie_colours,
border = border,
opacity = opacity,
segment_col = border_col
border_col = border_col
))

# Pie chart size formula
Expand Down Expand Up @@ -110,7 +110,7 @@ add_pie_charts <- function(df, admix_columns, lat_column, lon_column, pie_colour
#' @param cols vector of colours the same length as the number of clusters.
#' @param border numeric value of zero or greater.
#' @param opacity numeric value of zero to one.
#' @param segment_col string denoting colour of pie border.
#' @param border_col string denoting colour of pie border.
#'
#' @return A ggplot object.
#' @export
Expand All @@ -130,7 +130,7 @@ add_pie_charts <- function(df, admix_columns, lat_column, lon_column, pie_colour
#' build_pie_chart(df, location = "London")
build_pie_chart <- function(df, location, cols = NULL,
border = 0.3, opacity = 1,
segment_col = "black"){
border_col = "black"){

# Subset data.frame by site
df_site <- subset(df, df$site == location)
Expand Down Expand Up @@ -161,7 +161,7 @@ build_pie_chart <- function(df, location, cols = NULL,
x = ggplot2::unit(0.5, "npc"),
y = ggplot2::unit(0.5, "npc"),
r = ggplot2::unit(0.40, "npc"), # Issue #16
gp = grid::gpar(col = "black", fill = cluster_col, alpha = opacity, lwd = border+0.4)
gp = grid::gpar(col = border_col, fill = cluster_col, alpha = opacity, lwd = border+0.4)
)

# Plot
Expand All @@ -176,7 +176,7 @@ build_pie_chart <- function(df, location, cols = NULL,
plt <- ggplot2::ggplot(data = df_site)+
ggplot2::geom_bar(
ggplot2::aes(x = "", y = !!as.name("value"), fill = !!as.name("cluster")),
width = 1, stat = "identity", colour = segment_col,
width = 1, stat = "identity", colour = border_col,
show.legend = FALSE, linewidth = border, alpha = opacity
)+
ggplot2::coord_polar(theta = "y")+
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ map2 <- mapmixture(
boundary = c(xmin=-15, xmax=16, ymin=40, ymax=62),
pie_size = 1,
pie_border = 0.3,
pie_border_col = "white",
pie_opacity = 1,
land_colour = "#d9d9d9",
sea_colour = "#deebf7",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ map2 <- mapmixture(
boundary = c(xmin=-15, xmax=16, ymin=40, ymax=62),
pie_size = 1,
pie_border = 0.3,
pie_border_col = "white",
pie_opacity = 1,
land_colour = "#d9d9d9",
sea_colour = "#deebf7",
Expand Down
4 changes: 2 additions & 2 deletions man/build_pie_chart.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4c33aa4

Please sign in to comment.