Skip to content

Commit

Permalink
Updates internals and extensions chapters (#268)
Browse files Browse the repository at this point in the history
* adds detail to the ggproto introduction

* expands the explanation of ggproto syntax

* converts ggproto style guide to bulleted list

* foreshadows the output format when ggproto methods are printed

* attempts to structure final part as "advanced topics"

* tweaks comment on stateless ggproto objects

* starts extending "new themes" section

* comments out bad example

* adds section on complete themes per suggestion in #171

* starts section on registering new theme elements

* temporary fix to the register_theme_element() bug

* includes the stat_chull() example in new stat section

* adds the stat_density_common() example

* adds setup_data example for geom_spike

* use geom_barbell to illustrate combining geoms

* typo

* edits new coords section

* adds the scale_fill_random example

* adds facet_scatter() example

* tidies facet_scatter example

* start position_jitternormal example

* tidies the jitternormal example

* typo fix

* use fewer columns in code to avoid bs4_book display issue

* smoothes geom_barbell() text

* apply typo fixes from code review

Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>

* typo fix

Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>

* switch to third person pronouns

* removes comment on performance

* typo fix

* minor tweaks

* whitespace tweaks

* whitespace and comment capitalisation fixes

* fixes linewidth/size warning in extensions

---------

Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>
  • Loading branch information
djnavarro and thomasp85 authored Feb 8, 2023
1 parent a14ebbd commit 904d33b
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 88 deletions.
1 change: 1 addition & 0 deletions common.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library(ggplot2)
conflicted::conflict_prefer("Position", "ggplot2")
library(dplyr)
conflicted::conflict_prefer("filter", "dplyr")
conflicted::conflict_prefer("pull", "dplyr") # in case git2r is loaded
Expand Down
2 changes: 1 addition & 1 deletion ext-springs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set.seed(12L)
columns(1, 1 / 1.61, 1)
```

# Case Study: Springs {#spring1}
# A case study {#spring1}

To make the ideas in the previous chapter concrete, here we'll work through the process of building a new geom that looks like a spring.
This is a carefully crafted example: you're unlikely to actually want to use springs to visualise your data (so no geom already exists), and they're just complicated enough to illustrate the most important parts of the process.
Expand Down
11 changes: 10 additions & 1 deletion extending.Rmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@

# (PART) Extending ggplot2 {-}
# (PART) Advanced topics {-}

# Introduction {#advanced-topics .unnumbered}

```{r setup, include = FALSE}
source("common.R")
columns(1, 2 / 3)
```

As you become more fluent in ggplot2, you may find yourself wanting to use it in more advanced ways. You may want to write your own functions that create plots in a reusable fashion, or you may want to write your own packages that extend ggplot2. If this describes you, then the chapters in this part of the book are designed to get you started. In Chapter \@ref(programming) we discuss programming techniques you can use to create flexible and reusable ggplot2 visualisations. This is followed by Chapter \@ref(internals) which dives into the mechanics of what ggplot2 does when creating a plot, and Chapter \@ref(extensions) which builds upon this discussion to talk about how ggplot2 extensions are written. Finally, in order to make these ideas a little more concrete, Chapter \@ref(spring1) presents a worked example of developing a ggplot2 extension.
Loading

0 comments on commit 904d33b

Please sign in to comment.