diff --git a/R/geom_soccer_logos.R b/R/geom_soccer_logos.R
index 3591bd8..fe343b6 100644
--- a/R/geom_soccer_logos.R
+++ b/R/geom_soccer_logos.R
@@ -41,7 +41,7 @@
#'
#' df <- data.frame(
#' a = c(rep(1:6, 7), c(1, 2)),
-#' b = sort(c(rep(1:7, 6), c(8, 8)), decreasing = TRUE),
+#' b = sort(c(rep(2, 8, 6), c(1, 1)), decreasing = TRUE),
#' team_name = team_names
#' )
#'
diff --git a/README.Rmd b/README.Rmd
index 785ed5b..56c7a40 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -11,7 +11,8 @@ knitr::opts_chunk$set(
warning = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
- out.width = "100%"
+ out.width = "100%",
+ dpi = 300
)
```
@@ -36,11 +37,11 @@ pak::pak("tonyelhabr/soccerplotR")
## Examples
-```{r example, fig.width = 7, fig.height = 7, dpi=300}
+```{r example-1, fig.height=7, fig.width=7}
library(soccerplotR)
library(ggplot2)
-FONT <- 'Kanit'
+FONT <- "Kanit"
sysfonts::font_add_google(FONT)
showtext::showtext_auto()
showtext::showtext_opts(dpi = 300)
@@ -71,22 +72,50 @@ ggplot(df) +
label = team_name,
fill = team_name
),
- color = 'white',
+ color = "white",
family = FONT,
size = 10 / .pt,
nudge_y = -0.5
) +
- scale_fill_soccer(type = 'primary') +
+ scale_fill_soccer(type = "primary") +
theme_void() +
theme(
- plot.margin = margin(25, 25, 25, 25, 'pt')
+ plot.margin = margin(25, 25, 25, 25, "pt")
) +
- coord_cartesian(clip = 'off') +
+ coord_cartesian(clip = "off") +
labs(
- title = 'A random sample of 45 teams'
+ title = "A random sample of 45 teams"
) +
theme(
- plot.title.position = 'plot',
- plot.title = element_text(family = FONT, size = 18, hjust = 0.5, vjust = 1)
+ plot.title.position = "plot",
+ plot.title = element_text(family = FONT, size = 18, hjust = 0.5)
+ )
+```
+
+```{r example-2, fig.height=10, fig.width=7.5}
+team_names <- soccerplotR::valid_team_names("ENG")
+
+df <- data.frame(
+ team_name = team_names,
+ value = 1:length(team_names)
+)
+
+df$team_name <- factor(df$team_name, levels = df$team_name[order(df$value)])
+
+ggplot(df, aes(y = team_name, x = value)) +
+ geom_col(aes(color = team_name, fill = team_name), width = 0.8) +
+ scale_color_soccer(type = "secondary") +
+ scale_fill_soccer(alpha = 0.8) +
+ theme_minimal() +
+ theme(
+ plot.title.position = "plot",
+ plot.title = element_text(family = FONT, size = 18),
+ axis.text = element_text(family = FONT),
+ panel.grid.major.y = element_blank()
+ ) +
+ labs(
+ x = NULL,
+ y = NULL,
+ title = "English teams in {soccerplotR}"
)
```
diff --git a/README.md b/README.md
index b38b73d..12c2eb1 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ pak::pak("tonyelhabr/soccerplotR")
library(soccerplotR)
library(ggplot2)
-FONT <- 'Kanit'
+FONT <- "Kanit"
sysfonts::font_add_google(FONT)
showtext::showtext_auto()
showtext::showtext_opts(dpi = 300)
@@ -68,24 +68,54 @@ ggplot(df) +
label = team_name,
fill = team_name
),
- color = 'white',
+ color = "white",
family = FONT,
size = 10 / .pt,
nudge_y = -0.5
) +
- scale_fill_soccer(type = 'primary') +
+ scale_fill_soccer(type = "primary") +
theme_void() +
theme(
- plot.margin = margin(25, 25, 25, 25, 'pt')
+ plot.margin = margin(25, 25, 25, 25, "pt")
) +
- coord_cartesian(clip = 'off') +
+ coord_cartesian(clip = "off") +
labs(
- title = 'A random sample of 45 teams'
+ title = "A random sample of 45 teams"
) +
theme(
- plot.title.position = 'plot',
- plot.title = element_text(family = FONT, size = 18, hjust = 0.5, vjust = 1)
+ plot.title.position = "plot",
+ plot.title = element_text(family = FONT, size = 18, hjust = 0.5)
)
```
-
+
+
+``` r
+team_names <- soccerplotR::valid_team_names("ENG")
+
+df <- data.frame(
+ team_name = team_names,
+ value = 1:length(team_names)
+)
+
+df$team_name <- factor(df$team_name, levels = df$team_name[order(df$value)])
+
+ggplot(df, aes(y = team_name, x = value)) +
+ geom_col(aes(color = team_name, fill = team_name), width = 0.8) +
+ scale_color_soccer(type = "secondary") +
+ scale_fill_soccer(alpha = 0.8) +
+ theme_minimal() +
+ theme(
+ plot.title.position = "plot",
+ plot.title = element_text(family = FONT, size = 18),
+ axis.text = element_text(family = FONT),
+ panel.grid.major.y = element_blank()
+ ) +
+ labs(
+ x = NULL,
+ y = NULL,
+ title = "English teams in {soccerplotR}"
+ )
+```
+
+
diff --git a/data-raw/logo_scatter_for_package_logo.R b/data-raw/logo_scatter_for_package_logo.R
index 0242abc..d45d7af 100644
--- a/data-raw/logo_scatter_for_package_logo.R
+++ b/data-raw/logo_scatter_for_package_logo.R
@@ -38,7 +38,7 @@ p <- ggplot(df, aes(x = a, y = b)) +
coord_cartesian(xlim = c(0.5,7.5), ylim = c(0.5,6.5)) +
theme_void()
-
+BACKGROUND_COLOR <- "#60b922"
sticker(
p,
package = "soccerplotR",
@@ -54,7 +54,7 @@ sticker(
l_y = 1.75,
l_alpha = 0.2,
l_width = 5,
- h_fill = "#60b922",
+ h_fill = BACKGROUND_COLOR,
h_color = "black",
h_size = 0.8,
filename = "data-raw/logo.png",
@@ -80,5 +80,5 @@ ggsave(
height = 640,
units = "px",
dpi = 600,
- bg = "#222222"
+ bg = BACKGROUND_COLOR
)
diff --git a/man/figures/README-example-1.png b/man/figures/README-example-1-1.png
similarity index 100%
rename from man/figures/README-example-1.png
rename to man/figures/README-example-1-1.png
diff --git a/man/figures/README-example-2-1.png b/man/figures/README-example-2-1.png
new file mode 100644
index 0000000..7829c8b
Binary files /dev/null and b/man/figures/README-example-2-1.png differ