Skip to content

Commit

Permalink
better readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyelhabr committed Jan 21, 2024
1 parent 76ee878 commit 8f7f666
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 23 deletions.
2 changes: 1 addition & 1 deletion R/geom_soccer_logos.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#' )
#'
Expand Down
49 changes: 39 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ knitr::opts_chunk$set(
warning = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
out.width = "100%",
dpi = 300
)
```

Expand All @@ -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)
Expand Down Expand Up @@ -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}"
)
```
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
)
```

<img src="man/figures/README-example-1.png" width="100%" />
<img src="man/figures/README-example-1-1.png" width="100%" />

``` 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}"
)
```

<img src="man/figures/README-example-2-1.png" width="100%" />
6 changes: 3 additions & 3 deletions data-raw/logo_scatter_for_package_logo.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -80,5 +80,5 @@ ggsave(
height = 640,
units = "px",
dpi = 600,
bg = "#222222"
bg = BACKGROUND_COLOR
)
File renamed without changes
Binary file added man/figures/README-example-2-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 8f7f666

Please sign in to comment.