|
7 | 7 | #' @param tile Tile to be plotted.
|
8 | 8 | #' @param legend Legend for the classes
|
9 | 9 | #' @param palette A sequential RColorBrewer palette
|
10 |
| -#' @param tmap_options Named vector with optional tmap parameters |
11 |
| -#' graticules_labels_size (default: 0.7) |
12 |
| -#' legend_title_size (default: 1.5) |
13 |
| -#' legend_text_size (default: 1.2) |
14 |
| -#' legend_bg_color (default: "white") |
15 |
| -#' legend_bg_alpha (default: 0.5) |
| 10 | +#' @param scale Global scale for plot |
16 | 11 | #'
|
17 | 12 | #' @return A plot object
|
18 | 13 | #'
|
19 | 14 | .plot_class_vector <- function(tile,
|
20 | 15 | legend,
|
21 | 16 | palette,
|
22 |
| - tmap_options) { |
| 17 | + scale) { |
23 | 18 | # retrieve the segments for this tile
|
24 | 19 | sf_seg <- .segments_read_vec(tile)
|
25 | 20 | # check that segments have been classified
|
|
40 | 35 | palette = palette,
|
41 | 36 | rev = TRUE
|
42 | 37 | )
|
43 |
| - # set the tmap options |
44 |
| - tmap_options <- .plot_tmap_params(tmap_options) |
45 | 38 | # name the colors to match the labels
|
46 | 39 | names(colors) <- labels
|
47 | 40 | # join sf geometries
|
|
55 | 48 | palette = colors
|
56 | 49 | ) +
|
57 | 50 | tmap::tm_graticules(
|
58 |
| - labels.size = tmap_options[["graticules_labels_size"]] |
| 51 | + labels.size = as.numeric(.conf("tmap", "graticules_labels_size")) |
59 | 52 | ) +
|
60 | 53 | tmap::tm_compass() +
|
61 | 54 | tmap::tm_layout(
|
62 |
| - legend.show = TRUE, |
63 |
| - legend.outside = FALSE, |
64 |
| - scale = tmap_options[["scale"]], |
65 |
| - fontfamily = tmap_options[["font_family"]], |
66 |
| - legend.bg.color = tmap_options[["legend_bg_color"]], |
67 |
| - legend.bg.alpha = tmap_options[["legend_bg_alpha"]], |
68 |
| - legend.title.size = tmap_options[["legend_title_size"]], |
69 |
| - legend.text.size = tmap_options[["legend_text_size"]], |
70 |
| - legend.width = tmap_options[["legend_width"]], |
71 |
| - legend.position = tmap_options[["legend_position"]] |
| 55 | + scale = scale, |
| 56 | + legend.bg.color = .conf("tmap", "legend_bg_color"), |
| 57 | + legend.bg.alpha = as.numeric(.conf("tmap", "legend_bg_alpha")) |
72 | 58 | ) +
|
73 | 59 | tmap::tm_borders(lwd = 0.2)
|
74 | 60 | return(p)
|
|
82 | 68 | #' @param tile Tile to be plotted.
|
83 | 69 | #' @param labels_plot Labels to be plotted
|
84 | 70 | #' @param palette A sequential RColorBrewer palette
|
| 71 | +#' @param style Method to process the color scale |
| 72 | +#' ("cont", "order", "quantile", "fisher", |
| 73 | +#' "jenks", "log10") |
85 | 74 | #' @param rev Revert the color of the palette?
|
86 |
| -#' @param tmap_options Named vector with optional tmap parameters |
| 75 | +#' @param scale. Global map scale |
87 | 76 | #'
|
88 | 77 | #' @return A plot object
|
89 | 78 | #'
|
90 | 79 | .plot_probs_vector <- function(tile,
|
91 | 80 | labels_plot,
|
92 | 81 | palette,
|
| 82 | + style, |
93 | 83 | rev,
|
94 |
| - tmap_options) { |
| 84 | + scale) { |
95 | 85 | # verifies if stars package is installed
|
96 | 86 | .check_require_packages("stars")
|
97 | 87 | # verifies if tmap package is installed
|
|
116 | 106 | }
|
117 | 107 | # get the segements to be plotted
|
118 | 108 | sf_seg <- .segments_read_vec(tile)
|
119 |
| - # set the tmap options |
120 |
| - tmap_options <- .plot_tmap_params(tmap_options) |
| 109 | + |
121 | 110 | # plot the segments by facet
|
122 | 111 | p <- tmap::tm_shape(sf_seg) +
|
123 | 112 | tmap::tm_fill(labels_plot,
|
124 |
| - style = "cont", |
| 113 | + style = style, |
125 | 114 | palette = palette,
|
126 | 115 | midpoint = 0.5,
|
127 | 116 | title = labels[labels %in% labels_plot]) +
|
128 | 117 | tmap::tm_graticules(
|
129 |
| - labels.size = tmap_options[["graticules_labels_size"]] |
| 118 | + labels.size = as.numeric(.conf("tmap", "graticules_labels_size")) |
130 | 119 | ) +
|
131 | 120 | tmap::tm_facets() +
|
132 | 121 | tmap::tm_compass() +
|
133 | 122 | tmap::tm_layout(
|
134 |
| - scale = tmap_options[["scale"]], |
135 |
| - fontfamily = tmap_options[["font_family"]], |
136 |
| - legend.show = TRUE, |
137 |
| - legend.outside = FALSE, |
138 |
| - legend.bg.color = tmap_options[["legend_bg_color"]], |
139 |
| - legend.bg.alpha = tmap_options[["legend_bg_alpha"]], |
140 |
| - legend.title.size = tmap_options[["legend_title_size"]], |
141 |
| - legend.text.size = tmap_options[["legend_text_size"]], |
142 |
| - legend.width = tmap_options[["legend_width"]] |
| 123 | + scale = scale, |
| 124 | + legend.bg.color = .conf("tmap", "legend_bg_color"), |
| 125 | + legend.bg.alpha = as.numeric(.conf("tmap", "legend_bg_alpha")) |
143 | 126 | ) +
|
144 | 127 | tmap::tm_borders(lwd = 0.1)
|
145 | 128 |
|
|
153 | 136 | #' @noRd
|
154 | 137 | #' @param tile Tile to be plotted.
|
155 | 138 | #' @param palette A sequential RColorBrewer palette
|
| 139 | +#' @param style Method to process the color scale |
| 140 | +#' ("cont", "order", "quantile", "fisher", |
| 141 | +#' "jenks", "log10") |
156 | 142 | #' @param rev Revert the color of the palette?
|
157 |
| -#' @param tmap_options Named vector with optional tmap parameters |
| 143 | +#' @param scale Global map scale |
158 | 144 | #'
|
159 | 145 | #' @return A plot object
|
160 | 146 | #'
|
161 | 147 | .plot_uncertainty_vector <- function(tile,
|
162 | 148 | palette,
|
| 149 | + style, |
163 | 150 | rev,
|
164 |
| - tmap_options) { |
| 151 | + scale) { |
165 | 152 | # verifies if stars package is installed
|
166 | 153 | .check_require_packages("stars")
|
167 | 154 | # verifies if tmap package is installed
|
|
174 | 161 | }
|
175 | 162 | # get the segements to be plotted
|
176 | 163 | sf_seg <- .segments_read_vec(tile)
|
177 |
| - # set the tmap options |
178 |
| - tmap_options <- .plot_tmap_params(tmap_options) |
179 | 164 | # obtain the uncertainty type
|
180 | 165 | uncert_type <- .vi(tile)$band
|
181 | 166 | # plot the segments by facet
|
182 | 167 | p <- tmap::tm_shape(sf_seg) +
|
183 | 168 | tmap::tm_polygons(uncert_type,
|
184 | 169 | palette = palette,
|
185 |
| - style = "cont") + |
| 170 | + style = style) + |
186 | 171 | tmap::tm_graticules(
|
187 |
| - labels.size = tmap_options[["graticules_labels_size"]] |
| 172 | + labels.size = as.numeric(.conf("tmap", "graticules_labels_size")) |
188 | 173 | ) +
|
189 | 174 | tmap::tm_compass() +
|
190 | 175 | tmap::tm_layout(
|
191 |
| - legend.show = TRUE, |
192 |
| - legend.outside = FALSE, |
193 |
| - scale = tmap_options[["scale"]], |
194 |
| - fontfamily = tmap_options[["font_family"]], |
195 |
| - legend.bg.color = tmap_options[["legend_bg_color"]], |
196 |
| - legend.bg.alpha = tmap_options[["legend_bg_alpha"]], |
197 |
| - legend.title.size = tmap_options[["legend_title_size"]], |
198 |
| - legend.text.size = tmap_options[["legend_text_size"]], |
199 |
| - legend.width = tmap_options[["legend_width"]], |
200 |
| - legend.position = tmap_options[["legend_position"]] |
| 176 | + scale = scale, |
| 177 | + legend.bg.color = .conf("tmap", "legend_bg_color"), |
| 178 | + legend.bg.alpha = as.numeric(.conf("tmap", "legend_bg_alpha")) |
201 | 179 | ) +
|
202 | 180 | tmap::tm_borders(lwd = 0.2)
|
203 | 181 |
|
|
0 commit comments