You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.Rmd
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ Feature | Description |
35
35
[Callouts](#callouts) | Add a line and label in one call. |
36
36
[Axes reversal](#reverse) | Reverse the axis by specifying one argument to `axis()`. |
37
37
[Embedded functions](#embed) | Add extra plot features within a points call (no duplication of x/y values) |
38
+
[Change rendering order](#where) | Manipulate what order plot features are rendered by specifying the argument `where` |
38
39
[Compatibility with base](#base) | Can start a plot using `gsplot`, and add base R features afterwards. |
39
40
40
41
```{r table_plots, echo=FALSE, message=FALSE}
@@ -218,6 +219,37 @@ embedplot <- gsplot() %>%
218
219
embedplot
219
220
```
220
221
222
+
<aname="where"></a>
223
+
224
+
#### Change rendering order
225
+
226
+
For each plot feature that is added (`points`, `lines`, `callouts`, etc), you can specify if it should render in it's current position (after everything above it) or whether it should go before everything else. Simply add the argument `where = 'first'` or leave the default `where = "last"`.
227
+
228
+
```{r message=FALSE, warning=FALSE}
229
+
renderorderplot <- gsplot() %>%
230
+
points(1:5, 1:5, col = "blue", legend.name = "data pts") %>%
231
+
callouts(2,2, labels = "my note") %>%
232
+
legend(location = "topleft", legend_offset=0.5)
233
+
renderorderplot
234
+
```
235
+
236
+
Say we have the plot above, but would like to add two red points.
Easy to do with `gsplot`, but now the two red points are covering up features in the original plot. We can easily change this by using the `where` argument when adding to the plot. Specifying `where` will also update the order of the legend.
For each plot feature that is added (`points`, `lines`, `callouts`, etc), you can specify if it should render in it's current position (after everything above it) or whether it should go before everything else. Simply add the argument `where = 'first'` or leave the default `where = "last"`.
Easy to do with `gsplot`, but now the two red points are covering up features in the original plot. We can easily change this by using the `where` argument when adding to the plot. Specifying `where` will also update the order of the legend.
0 commit comments