You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
3.8 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. ---
  2. output: rmarkdown::github_document
  3. editor_options:
  4. chunk_output_type: console
  5. ---
  6. ```{r pkg-knitr-opts, include=FALSE}
  7. hrbrpkghelpr::global_opts()
  8. ```
  9. ```{r ragg, echo = FALSE}
  10. knitr::opts_chunk$set(
  11. dev = "ragg_png",
  12. cache = TRUE
  13. )
  14. ```
  15. ```{r badges, results='asis', echo=FALSE, cache=FALSE}
  16. hrbrpkghelpr::stinking_badges()
  17. ```
  18. ```{r description, results='asis', echo=FALSE, cache=FALSE}
  19. hrbrpkghelpr::yank_title_and_description()
  20. ```
  21. ## What's Inside The Tin
  22. The following functions are implemented:
  23. ```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
  24. hrbrpkghelpr::describe_ingredients()
  25. ```
  26. ## Installation
  27. ```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
  28. hrbrpkghelpr::install_block()
  29. ```
  30. ## Usage
  31. ```{r lib-ex}
  32. library(tibble)
  33. library(hrbragg)
  34. library(ggplot2)
  35. # current version
  36. packageVersion("hrbragg")
  37. ```
  38. For the moment, you'll need to install Inter:
  39. ```{r install-font, eval = FALSE}
  40. install_inter()
  41. ```
  42. ### Inspect the definitions of the feature codes:
  43. ```{r ex-00}
  44. str(inter_pkg, 1)
  45. data("feature_dict")
  46. feature_dict[feature_dict$tag %in% textshaping::get_font_features("Inter")[[1]],]
  47. ```
  48. ### Let's make a plot!
  49. ```{r ex-01}
  50. ggplot() +
  51. geom_point(
  52. data = mtcars,
  53. aes(mpg, wt, color = factor(cyl))
  54. ) +
  55. geom_label(
  56. aes(
  57. x = 15, y = 5.48,
  58. label = "<- A fairly useless annotation\n that uses the custom Inter\n variant by default."
  59. ),
  60. label.size = 0, hjust = 0, vjust = 1
  61. ) +
  62. labs(
  63. x = "Fuel efficiency (mpg)", y = "Weight (tons)",
  64. title = "Seminal ggplot2 scatterplot example",
  65. subtitle = "A plot that is only useful for demonstration purposes",
  66. caption = "Brought to you by the letter 'g'"
  67. ) -> gg1
  68. ```
  69. ### Dark & light mode support with just a parameter change!
  70. ```{r dark-mode-01}
  71. gg1 + theme_inter(grid = "XY", mode = "dark")
  72. ```
  73. Note the ligatures aren't as nice in Goldman Sans
  74. ```{r dark-mode-01-rc}
  75. gg1 + theme_rc(grid = "XY", mode = "dark")
  76. ```
  77. ### Note the ligatures aren't as nice in or Roboto Condensed
  78. ```{r dark-mode-01-gs}
  79. gg1 + theme_gs(grid = "XY", mode = "dark")
  80. ```
  81. ```{r light-mode-01}
  82. gg1 + theme_inter(grid = "XY", mode = "light")
  83. ```
  84. ```{r light-mode-01-rc}
  85. gg1 + theme_rc(grid = "XY", mode = "light")
  86. ```
  87. ```{r light-mode-01-gs}
  88. gg1 + theme_gs(grid = "XY", mode = "light")
  89. ```
  90. ### Making sure we got all the various plot components styled
  91. ```{r ex-02}
  92. ggplot() +
  93. geom_point(
  94. data = mpg,
  95. aes(displ, hwy, color = trans)
  96. ) +
  97. facet_wrap(
  98. vars(cyl, drv), scales = "free", drop = TRUE
  99. ) +
  100. labs(
  101. x = "Displacement", y = "Highway",
  102. title = "Another seminal ggplot2 scatterplot example",
  103. subtitle = "A plot that is only useful for demonstration purposes",
  104. caption = "Brought to you by the letter 'g'"
  105. ) -> gg2
  106. ```
  107. ```{r light-mode-02, fig.width=1400/96, fig.height=700/96}
  108. gg2 + theme_inter(grid = "XY", mode = "light")
  109. ```
  110. ```{r dark-mode-02, fig.width=1400/96, fig.height=700/96}
  111. gg2 + theme_inter(grid = "XY", mode = "dark")
  112. ```
  113. ### Here's a way to preview any variants you create:
  114. ```{r preview-00, fig.width=600/96, fig.height=1300/96}
  115. preview_variant(inter_pkg)
  116. ```
  117. ```{r preview-01, fig.width=400/96, fig.height=300/96}
  118. reconfigure_font(
  119. family = "Trattatello",
  120. width = "normal",
  121. ligatures = "discretionary",
  122. calt = 1, tnum = 1, case = 1,
  123. dlig = 1, kern = 1,
  124. zero = 0, salt = 0
  125. ) -> trat
  126. preview_variant(trat)
  127. ```
  128. ```{r preview-02, fig.width=600/96, fig.height=1100/96}
  129. reconfigure_font(
  130. family = "Barlow",
  131. width = "normal",
  132. ligatures = "standard",
  133. tnum = 1, kern = 1
  134. ) -> barlow
  135. preview_variant(barlow)
  136. ```
  137. ## hrbragg Metrics
  138. ```{r cloc, echo=FALSE}
  139. cloc::cloc_pkg_md()
  140. ```
  141. ## Code of Conduct
  142. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.