|
13 | 13 | #' - `render_bg`: Renders background elements.
|
14 | 14 | #' - `render_axis_h`: Renders the horizontal axes.
|
15 | 15 | #' - `render_axis_v`: Renders the vertical axes.
|
| 16 | +#' - `backtransform_range(panel_params)`: Extracts the panel range provided |
| 17 | +#' in `panel_params` (created by `setup_panel_params()`, see below) and |
| 18 | +#' back-transforms to data coordinates. This back-transformation can be needed |
| 19 | +#' for coords such as `coord_trans()` where the range in the transformed |
| 20 | +#' coordinates differs from the range in the untransformed coordinates. Returns |
| 21 | +#' a list of two ranges, `x` and `y`, and these correspond to the variables |
| 22 | +#' mapped to the `x` and `y` aesthetics, even for coords such as `coord_flip()` |
| 23 | +#' where the `x` aesthetic is shown along the y direction and vice versa. |
16 | 24 | #' - `range(panel_params)`: Extracts the panel range provided
|
17 | 25 | #' in `panel_params` (created by `setup_panel_params()`, see below) and
|
18 |
| -#' back-transforms to data coordinates. This back-transformation is needed |
19 |
| -#' for coords such as `coord_flip()`, `coord_polar()`, `coord_trans()` where |
20 |
| -#' the range in the transformed coordinates differs from the range in the |
21 |
| -#' untransformed coordinates. |
| 26 | +#' returns it. Unlike `backtransform_range()`, this function does not perform |
| 27 | +#' any back-transformation and instead returns final transformed coordinates. Returns |
| 28 | +#' a list of two ranges, `x` and `y`, and these correspond to the variables |
| 29 | +#' mapped to the `x` and `y` aesthetics, even for coords such as `coord_flip()` |
| 30 | +#' where the `x` aesthetic is shown along the y direction and vice versa. |
22 | 31 | #' - `transform`: Transforms x and y coordinates.
|
23 | 32 | #' - `distance`: Calculates distance.
|
24 | 33 | #' - `is_linear`: Returns `TRUE` if the coordinate system is
|
@@ -84,11 +93,22 @@ Coord <- ggproto("Coord",
|
84 | 93 | # transform range given in transformed coordinates
|
85 | 94 | # back into range in given in (possibly scale-transformed)
|
86 | 95 | # data coordinates
|
87 |
| - range = function(panel_params) { |
| 96 | + backtransform_range = function(self, panel_params) { |
88 | 97 | warning(
|
89 |
| - "range backtransformation not implemented in this coord; plot may be wrong.", |
| 98 | + "range backtransformation not implemented in this coord; results may be wrong.", |
90 | 99 | call. = FALSE
|
91 | 100 | )
|
| 101 | + # return result from range function for backwards compatibility |
| 102 | + # before ggplot2 3.0.1 |
| 103 | + self$range(panel_params) |
| 104 | + }, |
| 105 | + |
| 106 | + # return range stored in panel_params |
| 107 | + range = function(panel_params) { |
| 108 | + warning( |
| 109 | + "range calculation not implemented in this coord; results may be wrong.", |
| 110 | + call. = FALSE |
| 111 | + ) |
92 | 112 | list(x = panel_params$x.range, y = panel_params$y.range)
|
93 | 113 | },
|
94 | 114 |
|
|
0 commit comments