Skip to content

Commit

Permalink
Merge pull request #8 from pabsantos/7-add-option-to-change-font-size
Browse files Browse the repository at this point in the history
7 add option to change font size
  • Loading branch information
pabsantos authored Aug 28, 2023
2 parents 3a490b0 + e2e1f61 commit cff2c75
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: onsvplot
Title: Apply ONSV Style for Ggplot Graphics
Version: 0.2.1
Version: 0.2.2
Authors@R:
person(
given = c("Pedro", "Augusto", "Borges"),
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# onsvplot 0.2.2

* Add new parameter to `theme_onsv()` (#7): Now it is possible to change `basesize` of the font used in the plot

# onsvplot 0.2.1

* Add two new parameters to `theme_onsv()` (#3): `plot.title.position = "plot"` and `plot.caption.position = "plot"`.

* Add bottom margin to `title` element.


# onsvplot 0.2.0

* Updates the package name to `onsvplot`. The `obsplot` package already exists, therefore it was necessary to change the previous name. (#4)
Expand Down
16 changes: 9 additions & 7 deletions R/theme_onsv.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' `theme_onsv()` is used to apply the ONSV theme to a ggplot graphics.
#'
#' @param basesize A number to define font base size
#'
#' @return A custom `theme()` object.
#' @export
#'
Expand All @@ -11,7 +13,7 @@
#' ggplot(data = iris, aes(x = Sepal.Width, y = Sepal.Length)) +
#' geom_point() +
#' theme_onsv()
theme_onsv <- function() {
theme_onsv <- function(basesize = 10) {
if (.Platform$OS.type == "windows") {
font <- "sans"
} else {
Expand All @@ -21,14 +23,14 @@ theme_onsv <- function() {
ggplot2::theme(
plot.title = ggplot2::element_text(
family = font,
size = 14,
size = basesize + 4,
face = "bold",
color = "grey10",
margin = ggplot2::margin(t = 0, r = 0, b = 5, l = 0),
),
plot.subtitle = ggplot2::element_text(
family = font,
size = 12,
size = basesize + 2,
margin = ggplot2::margin(t = 5, r = 0, b = 5, l = 0),
color = "grey20"
),
Expand All @@ -42,19 +44,19 @@ theme_onsv <- function() {
legend.key = ggplot2::element_blank(),
legend.text = ggplot2::element_text(
family = font,
size = 10,
size = basesize,
color = "grey20"
),
legend.margin = ggplot2::margin(t = 0, r = 0, b = 0, l = -10),
axis.title = ggplot2::element_text(
family = font,
size = 10,
size = basesize,
color = "grey10"
),
axis.ticks = ggplot2::element_blank(),
axis.text = ggplot2::element_text(
family = font,
size = 9,
size = basesize - 1,
color = "grey30"
),
panel.grid.minor = ggplot2::element_blank(),
Expand All @@ -68,6 +70,6 @@ theme_onsv <- function() {
),
panel.background = ggplot2::element_rect(color = "white", fill = "white"),
strip.background = ggplot2::element_rect(fill = "white"),
strip.text = ggplot2::element_text(size = 12, hjust = 0)
strip.text = ggplot2::element_text(size = basesize + 2, hjust = 0)
)
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +

## Citation

If you want to cite this package, you can cite as :
If you want to cite this package, you can cite as:

```{r citation, echo=FALSE}
citation("onsvplot")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +

## Citation

If you want to cite this package, you can cite as :
If you want to cite this package, you can cite as:

#> To cite package 'onsvplot' in publications use:
#>
#> Santos PAB (2023). _onsvplot: Apply ONSV Style for Ggplot Graphics_.
#> R package version 0.2.1, <https://www.github.com/pabsantos/onsvplot>.
#> R package version 0.2.2, <https://www.github.com/pabsantos/onsvplot>.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {onsvplot: Apply ONSV Style for Ggplot Graphics},
#> author = {Pedro Augusto Borges Santos},
#> year = {2023},
#> note = {R package version 0.2.1},
#> note = {R package version 0.2.2},
#> url = {https://www.github.com/pabsantos/onsvplot},
#> }
5 changes: 4 additions & 1 deletion man/theme_onsv.Rd

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

0 comments on commit cff2c75

Please sign in to comment.