Skip to content

Commit e52494b

Browse files
committed
fixes key.width issue
1 parent 9d2a86e commit e52494b

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

R/plot.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
kw_dflt = function(x, key.pos) {
2-
if (is.null(key.pos) || key.pos <= 0)
3-
lcm(0)
2+
if (is.null(key.pos) || key.pos == 0) # no key:
3+
return(lcm(0))
4+
5+
font_scale = par("ps") / 12
6+
if (key.pos == -1)
7+
lcm(1.8 * font_scale)
48
else if (key.pos %in% c(2, 4) && (is.character(x[[1]]) || is.factor(x[[1]]))) {
59
strings = if (is.factor(x[[1]]))
610
levels(x[[1]])
711
else
812
x[[1]]
9-
lcm(cm(max(strwidth(strings, "inches"))) * 1.3 + par("ps")/12) # cm
13+
lcm(cm(max(strwidth(strings, "inches"))) * 1.3 + font_scale) # cm
14+
#lcm(cm(max(strwidth(strings, "inches"))) * 1.3) # cm
1015
} else
11-
# lcm(1.8 * par("ps")/12)
12-
lcm(1.8)
16+
lcm(1.8 * font_scale)
1317
}
1418

1519

tests/plot.Rout.save

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
2+
R version 4.3.2 (2023-10-31) -- "Eye Holes"
33
Copyright (C) 2023 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu (64-bit)
55

@@ -88,9 +88,11 @@ Type 'q()' to quit R.
8888
+ plot(nc, axes = TRUE)
8989
+ plot(nc, col="lightgrey")
9090
+ plot(st_centroid(nc), add = TRUE, col = 1)
91-
+ nc %>%
91+
+ if ("geometry" %in% names(nc)) {
92+
+ nc %>%
9293
+ select(geometry) %>%
9394
+ plot()
95+
+ }
9496
+
9597
+ nc$f = cut(nc[[1]], 5)
9698
+ plot(nc["f"], key.pos = 1)
@@ -150,4 +152,4 @@ There were 13 warnings (use warnings() to see them)
150152
>
151153
> proc.time()
152154
user system elapsed
153-
4.822 0.828 4.857
155+
3.111 1.417 3.015

tests/read.Rout.save

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"
3-
Copyright (C) 2022 The R Foundation for Statistical Computing
2+
R version 4.3.2 (2023-10-31) -- "Eye Holes"
3+
Copyright (C) 2023 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu (64-bit)
55

66
R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -327,10 +327,10 @@ First 3 features:
327327
>
328328
> if ("GML" %in% st_drivers()$name) {
329329
+ gml = system.file("gml/fmi_test.gml", package = "sf")
330-
+ print(dim(st_read(gml, quiet = TRUE)))
330+
+ print(dim(st_read(gml, quiet = TRUE, use_stream = FALSE)))
331331
+ gml = system.file("gml/20170930_OB_530964_UKSH.xml.gz", package = "sf")
332-
+ print(dim(st_read(gml, layer = "Parcely", quiet = TRUE)))
333-
+ print(dim(st_read(gml, layer = "Parcely", int64_as_string=TRUE, quiet = TRUE)))
332+
+ print(dim(st_read(gml, layer = "Parcely", quiet = TRUE, use_stream = FALSE)))
333+
+ print(dim(st_read(gml, layer = "Parcely", int64_as_string=TRUE, quiet = TRUE, use_stream = FALSE)))
334334
+ }
335335
[1] 22 11
336336
[1] 644 25
@@ -376,4 +376,4 @@ Error : wkt parse error.
376376
>
377377
> proc.time()
378378
user system elapsed
379-
2.288 0.818 2.281
379+
1.255 1.397 1.179

0 commit comments

Comments
 (0)