Skip to content

Commit cc3b86d

Browse files
committed
refactor: Trailing newlines/tests in 'R' deleted
* Trailing newlines/tests in files in `R` directory have been deleted. * Do note every geom with a test in a `FALSE` block in `R` now has a test in the `tests` directory run by `{testthat}`.
1 parent 641b481 commit cc3b86d

19 files changed

+1
-305
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ggpattern
22
Type: Package
33
Title: 'ggplot2' Pattern Geoms
4-
Version: 1.1.0-2
4+
Version: 1.1.0-3
55
Authors@R: c(person("Mike", "FC", role = "aut",
66
email = "mikefc@coolbutuseless.com"),
77
person("Trevor L", "Davis", role = c("aut", "cre"),

R/geom-.R

-88
Original file line numberDiff line numberDiff line change
@@ -377,91 +377,3 @@ draw_key_crossbar_pattern <- function(data, params, size, aspect_ratio = 1) {
377377
key_grob_line
378378
)
379379
}
380-
381-
382-
383-
384-
if (FALSE) {
385-
library(ggplot2)
386-
library(dplyr)
387-
388-
plot_df <- mpg %>% filter(manufacturer %in% c('lincoln', 'mercury', 'audi'))
389-
390-
ggplot(plot_df, aes(x = manufacturer)) +
391-
geom_bar_pattern(
392-
aes(
393-
pattern_angle = manufacturer,
394-
pattern = manufacturer,
395-
pattern_fill = manufacturer
396-
),
397-
fill = 'white',
398-
colour = 'black',
399-
# pattern_angle = 10,
400-
pattern_density = 0.2,
401-
pattern_spacing = 0.03,
402-
pattern_alpha = 0.3,
403-
# pattern_fill = 'darkgreen',
404-
pattern_colour = NA,
405-
pattern_key_scale_factor = 1.2
406-
) +
407-
# geom_bar_pattern(
408-
# aes(
409-
# pattern_angle = manufacturer,
410-
# pattern = manufacturer
411-
# ),
412-
# fill = NA,
413-
# colour = 'black',
414-
# # pattern_angle = 10,
415-
# pattern_density = 0.1,
416-
# pattern_spacing = 0.021,
417-
# pattern_alpha = 0.5,
418-
# pattern_xoffset = 0.03
419-
# ) +
420-
# theme_void() +
421-
theme_bw() +
422-
labs(title = "ggpattern::geom_bar_pattern()") +
423-
scale_pattern_density_discrete() +
424-
scale_pattern_manual(values = c(lincoln = 'stripe', mercury = 'crosshatch', audi = 'stripe')) +
425-
theme(
426-
legend.key.size = unit(3, 'cm')#,
427-
# legend.justification = c(1, 0),
428-
# legend.position = c(0.9, 0.1)
429-
) +
430-
coord_fixed(ratio = 0.25) +
431-
# facet_wrap(~manufacturer) +
432-
NULL
433-
434-
435-
pdf("working/test.pdf", width = 8, height = 4);
436-
p + coord_fixed(ratio = 0.5);
437-
# p
438-
dev.off()
439-
440-
}
441-
442-
443-
444-
if (FALSE) {
445-
df <- data_frame(
446-
x = c(0.5, 1, 1.5, 2, 2.5),
447-
y = sqrt(c(8, 2, 1, 0.5, 0.25))
448-
)
449-
450-
ggplot(df, aes(x, y)) +
451-
geom_point() +
452-
geom_line()
453-
454-
}
455-
456-
457-
458-
459-
460-
461-
462-
463-
464-
465-
466-
467-

R/geom-bin2d.R

-15
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,3 @@ geom_bin2d_pattern <- function(mapping = NULL, data = NULL,
2323
)
2424
)
2525
}
26-
27-
28-
29-
30-
if(FALSE) {
31-
library(ggplot2)
32-
33-
ggplot(diamonds, aes(x, y)) + xlim(4, 10) + ylim(4, 10) +
34-
geom_bin2d_pattern(aes(pattern_density = ..density..), fill = 'white', bins = 5) +
35-
theme_bw() +
36-
labs(title = "ggpattern::geom_bin2d()")
37-
38-
}
39-
40-

R/geom-boxplot.R

-1
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,3 @@ GeomBoxplotPattern <- ggproto(
176176

177177
rename_size = TRUE
178178
)
179-

R/geom-crossbar.R

-31
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ GeomCrossbarPattern <- ggproto(
9595
for (varname in names(pattern_aesthetics)) {
9696
box[[varname]] <- data[[varname]]
9797
}
98-
# ))
9998
} else {
10099
# No notch
101100
box <- new_data_frame(list(
@@ -124,33 +123,3 @@ GeomCrossbarPattern <- ggproto(
124123
},
125124
rename_size = TRUE
126125
)
127-
128-
129-
if (FALSE) {
130-
library(ggplot2)
131-
132-
df <- data_frame(
133-
trt = factor(c(1, 1, 2, 2)),
134-
resp = c(1, 5, 3, 4),
135-
group = factor(c(1, 2, 1, 2)),
136-
upper = c(1.1, 5.3, 3.3, 4.2),
137-
lower = c(0.8, 4.6, 2.4, 3.6)
138-
)
139-
140-
ggplot(df, aes(trt, resp, colour = group)) +
141-
geom_crossbar_pattern(aes(ymin = lower, ymax = upper), width = 0.2) +
142-
theme_bw() +
143-
labs(title = "ggpattern::geom_crossbar_pattern()")
144-
}
145-
146-
147-
148-
149-
150-
151-
152-
153-
154-
155-
156-

R/geom-density.R

-15
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,3 @@ GeomDensityPattern <- ggproto(
4747
),
4848
rename_size = TRUE
4949
)
50-
51-
52-
53-
if (FALSE) {
54-
library(ggplot2)
55-
56-
ggplot(mtcars) +
57-
geom_density_pattern(aes(x=mpg, fill=as.factor(cyl), pattern = as.factor(cyl))) +
58-
theme_bw() +
59-
labs(title = "ggpattern::geom_density_pattern()")
60-
}
61-
62-
63-
64-

R/geom-map.R

-43
Original file line numberDiff line numberDiff line change
@@ -120,46 +120,3 @@ GeomMapPattern <- ggproto(
120120

121121
required_aes = c("map_id")
122122
)
123-
124-
125-
126-
127-
if (FALSE) {
128-
129-
library(ggplot2)
130-
library(maps)
131-
132-
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
133-
134-
states_map <- map_data("state")
135-
ggplot(crimes, aes(map_id = state)) +
136-
geom_map_pattern(
137-
aes(
138-
# fill = Murder,
139-
pattern_spacing = state,
140-
pattern_density = state,
141-
pattern_angle = state,
142-
pattern = state
143-
),
144-
fill = 'white',
145-
col = "blue",
146-
lwd = 2,
147-
map = states_map
148-
) +
149-
expand_limits(x = states_map$long, y = states_map$lat) +
150-
coord_map() +
151-
theme_bw() +
152-
labs(title = "ggpattern::geom_map_pattern()")
153-
154-
155-
}
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-

R/geom-polygon.R

-40
Original file line numberDiff line numberDiff line change
@@ -199,43 +199,3 @@ GeomPolygonPattern <- ggproto("GeomPolygonPattern", GeomPolygon,
199199

200200
rename_size = TRUE
201201
)
202-
203-
if (FALSE) {
204-
library(ggplot2)
205-
ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
206-
207-
values <- data.frame(
208-
id = ids,
209-
value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
210-
)
211-
212-
positions <- data.frame(
213-
id = rep(ids, each = 4),
214-
x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
215-
0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
216-
y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
217-
2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
218-
)
219-
220-
# Currently we need to manually merge the two together
221-
datapoly <- merge(values, positions, by = c("id"))
222-
223-
p <- ggplot(datapoly, aes(x = x, y = y)) +
224-
geom_polygon_pattern(aes(fill = value, group = id), col = "red", lwd = 2)
225-
p
226-
227-
}
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-

R/geom-rect.R

-47
Original file line numberDiff line numberDiff line change
@@ -166,50 +166,3 @@ rect_to_poly <- function(xmin, xmax, ymin, ymax) {
166166
x = c(xmin, xmax, xmax, xmin, xmin)
167167
))
168168
}
169-
170-
171-
172-
if (FALSE) {
173-
library(ggplot2)
174-
library(dplyr)
175-
176-
plot_df <- data.frame(
177-
xmin = c(0, 10),
178-
xmax = c(8, 18),
179-
ymin = c(0, 10),
180-
ymax = c(5, 19),
181-
type = c('a', 'b'),
182-
angle = c(45, 0),
183-
pname = c('circle', 'circle'),
184-
pcolour = c('red', 'blue'),
185-
pspace = c(0.03, 0.05),
186-
stringsAsFactors = FALSE
187-
)
188-
189-
190-
p <- ggplot(plot_df) +
191-
geom_rect_pattern(
192-
aes(
193-
xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax,
194-
# pattern = I(pname),
195-
pattern_angle = I(angle),
196-
pattern_colour = I(pcolour),
197-
pattern_spacing = I(pspace)
198-
),
199-
pattern = 'circle',
200-
fill = 'white',
201-
colour = 'black',
202-
pattern_density = 0.3
203-
) +
204-
theme_bw() +
205-
labs(title = "ggpattern::geom_rect_pattern()")
206-
207-
208-
209-
210-
pdf("working/test.pdf")
211-
p
212-
dev.off()
213-
214-
215-
}

R/geom-violin.R

-12
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,3 @@ GeomViolinPattern <- ggproto(
115115

116116
rename_size = TRUE
117117
)
118-
119-
120-
121-
if (FALSE) {
122-
library(ggplot2)
123-
library(dplyr)
124-
125-
ggplot(mtcars, aes(as.factor(cyl), mpg)) +
126-
geom_violin_pattern(aes(pattern = as.factor(cyl))) +
127-
theme_bw() +
128-
labs(title = "ggpattern::geom_violin_pattern()")
129-
}

R/ggpattern-deprecated.R

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
# #'
66
# #' @name ggpattern-deprecated
77
# NULL
8-

R/scale-pattern-brewer.R

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
#' Sequential, diverging and qualitative colour scales from colorbrewer.org
53
#'
@@ -153,4 +151,3 @@ scale_pattern_fill2_distiller <- function(..., type = "seq", palette = 1, direct
153151
# }
154152
# binned_scale(aesthetics, "fermenter", binned_pal(brewer_pal(type, palette, direction)), na.value = na.value, guide = guide, ...)
155153
# }
156-

R/scale-pattern-colour.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Continuous and binned colour scales
43
#'

R/scale-pattern-gradient.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Gradient colour scales
43
#'

R/scale-pattern-grey.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Sequential grey colour scales
43
#'

R/scale-pattern-hue.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Evenly spaced colours for discrete data
43
#'

R/scale-pattern-linetype.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Scale for line patterns
43
#'

R/scale-pattern-size.R

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#-----------------------------------------------------------------------------
32
#' Scales for area or radius
43
#'
@@ -89,4 +88,3 @@ scale_pattern_size_ordinal <- function(..., range = c(2, 6)) {
8988
...
9089
)
9190
}
92-

R/scale-pattern-viridis.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
#' Viridis colour scales from viridisLite
43
#'

0 commit comments

Comments
 (0)