Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22d715d

Browse files
Fixes/workaround for upcoming (> v3.4.3) ggplot2 release (#2301)
1 parent 270d20e commit 22d715d

File tree

13 files changed

+325
-298
lines changed

13 files changed

+325
-298
lines changed

‎NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 4.10.2.9000
22

3+
## Improvements
4+
5+
* `ggplotly()` now works better with the development version of ggplot2 (> v3.4.3). (#2301)
6+
37
## Bug fixes
48

59
* Closed #1947: `ggplotly()` now correctly handles `geom_vline`/`geom_hline` with empty data. Previously, if `geom_vline`/`geom_hline` was passed an empty data frame, it would result in an error. The plot is drawn even if no lines are found; this is the same behavior as `ggplot2`.

‎R/ggplotly.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ gg2list <- function(p, width = NULL, height = NULL,
725725
call. = FALSE
726726
)
727727
}
728-
# determine axis types (note: scale_name may go away someday)
729-
# https://github.com/hadley/ggplot2/issues/1312
730-
isDate <- isTRUE(sc$scale_name%in%c("date", "datetime"))
728+
729+
# determine axis types
730+
isDate <- inherits(sc, c("ScaleContinuousDatetime", "ScaleContinuousDate"))
731731
isDateType <- isDynamic && isDate
732-
isDiscrete <- identical(sc$scale_name, "position_d")
732+
isDiscrete <- inherits(sc, "ScaleDiscretePosition")
733733
isDiscreteType <- isDynamic && isDiscrete
734734

735735
# In 3.2.x .major disappeared in favor of break_positions()
@@ -1512,7 +1512,14 @@ scales_add_missing <- function(plot, aesthetics) {
15121512
# towards ggproto methods attached to `plot$guides`
15131513
# -------------------------------------------------------------------------
15141514
get_gdefs_ggproto <- function(scales, theme, plot, layers) {
1515-
guides <- plot$guides$setup(scales)
1515+
1516+
# Unfortunate duplication of logic in tidyverse/ggplot2#5428
1517+
# which ensures a 1:1 mapping between aesthetics and scales
1518+
aesthetics <- lapply(scales, `[[`, "aesthetics")
1519+
scales <- rep.int(scales, lengths(aesthetics))
1520+
aesthetics <- unlist(aesthetics, recursive = FALSE, use.names = FALSE)
1521+
1522+
guides <- plot$guides$setup(scales, aesthetics = aesthetics)
15161523
guides$train(scales, theme$legend.direction, plot$labels)
15171524
if (length(guides$guides) > 0) {
15181525
guides$merge()

‎R/layers2traces.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ layers2traces <- function(data, prestats_data, layout, p) {
7979
discreteScales <- list()
8080
for (sc in p$scales$non_position_scales()$scales) {
8181
if (sc$is_discrete()) {
82-
discreteScales[[sc$aesthetics]] <- sc
82+
nm <- paste(sc$aesthetics, collapse = "_")
83+
discreteScales[[nm]] <- sc
8384
}
8485
}
8586
# Convert "high-level" geoms to their "low-level" counterpart

‎inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,70 +14,70 @@
1414
"x": [
1515
21,
1616
21,
17-
22.8,
18-
21.4,
19-
18.7,
20-
18.1,
21-
14.3,
22-
24.4,
23-
22.8,
24-
19.2,
25-
17.8,
26-
16.4,
27-
17.3,
28-
15.2,
17+
22.800000000000001,
18+
21.399999999999999,
19+
18.699999999999999,
20+
18.100000000000001,
21+
14.300000000000001,
22+
24.399999999999999,
23+
22.800000000000001,
24+
19.199999999999999,
25+
17.800000000000001,
26+
16.399999999999999,
27+
17.300000000000001,
28+
15.199999999999999,
2929
10.4,
3030
10.4,
31-
14.7,
32-
32.4,
33-
30.4,
34-
33.9,
31+
14.699999999999999,
32+
32.399999999999999,
33+
30.399999999999999,
34+
33.899999999999999,
3535
21.5,
3636
15.5,
37-
15.2,
38-
13.3,
39-
19.2,
40-
27.3,
37+
15.199999999999999,
38+
13.300000000000001,
39+
19.199999999999999,
40+
27.300000000000001,
4141
26,
42-
30.4,
43-
15.8,
44-
19.7,
42+
30.399999999999999,
43+
15.800000000000001,
44+
19.699999999999999,
4545
15,
46-
21.4
46+
21.399999999999999
4747
],
4848
"y": [
49-
2.62,
49+
2.6200000000000001,
5050
2.875,
51-
2.32,
52-
3.215,
53-
3.44,
51+
2.3199999999999998,
52+
3.2149999999999999,
53+
3.4399999999999999,
5454
3.46,
55-
3.57,
56-
3.19,
57-
3.15,
58-
3.44,
59-
3.44,
60-
4.07,
55+
3.5699999999999998,
56+
3.1899999999999999,
57+
3.1499999999999999,
58+
3.4399999999999999,
59+
3.4399999999999999,
60+
4.0700000000000003,
6161
3.73,
62-
3.78,
62+
3.7799999999999998,
6363
5.25,
64-
5.424,
65-
5.345,
66-
2.2,
64+
5.4240000000000004,
65+
5.3449999999999998,
66+
2.2000000000000002,
6767
1.615,
6868
1.835,
69-
2.465,
69+
2.4649999999999999,
7070
3.52,
71-
3.435,
72-
3.84,
73-
3.845,
74-
1.935,
75-
2.14,
76-
1.513,
77-
3.17,
71+
3.4350000000000001,
72+
3.8399999999999999,
73+
3.8450000000000002,
74+
1.9350000000000001,
75+
2.1400000000000001,
76+
1.5129999999999999,
77+
3.1699999999999999,
7878
2.77,
79-
3.57,
80-
2.78
79+
3.5699999999999998,
80+
2.7799999999999998
8181
],
8282
"text": [
8383
"mpg: 21.0<br />wt: 2.620<br />nms: Mazda RX4",
@@ -153,10 +153,10 @@
153153
"autocolorscale": false,
154154
"color": "rgba(0,0,0,1)",
155155
"opacity": 1,
156-
"size": 5.66929133858268,
156+
"size": 5.6692913385826778,
157157
"symbol": "circle",
158158
"line": {
159-
"width": 1.88976377952756,
159+
"width": 1.8897637795275593,
160160
"color": "rgba(0,0,0,1)"
161161
}
162162
},
@@ -170,17 +170,17 @@
170170
],
171171
"layout": {
172172
"margin": {
173-
"t": 25.7412480974125,
174-
"r": 7.30593607305936,
175-
"b": 39.6955859969559,
176-
"l": 31.4155251141553
173+
"t": 25.74124809741248,
174+
"r": 7.3059360730593621,
175+
"b": 39.69558599695587,
176+
"l": 31.415525114155255
177177
},
178178
"plot_bgcolor": "rgba(235,235,235,1)",
179179
"paper_bgcolor": "rgba(255,255,255,1)",
180180
"font": {
181181
"color": "rgba(0,0,0,1)",
182182
"family": "",
183-
"size": 14.6118721461187
183+
"size": 14.611872146118724
184184
},
185185
"xaxis": {
186186
"domain": [
@@ -191,8 +191,8 @@
191191
"type": "linear",
192192
"autorange": false,
193193
"range": [
194-
9.225,
195-
35.075
194+
9.2249999999999996,
195+
35.074999999999996
196196
],
197197
"tickmode": "array",
198198
"ticktext": [
@@ -223,29 +223,29 @@
223223
"nticks": null,
224224
"ticks": "outside",
225225
"tickcolor": "rgba(51,51,51,1)",
226-
"ticklen": 3.65296803652968,
227-
"tickwidth": 0.66417600664176,
226+
"ticklen": 3.6529680365296811,
227+
"tickwidth": 0.66417600664176002,
228228
"showticklabels": true,
229229
"tickfont": {
230230
"color": "rgba(77,77,77,1)",
231231
"family": "",
232-
"size": 11.689497716895
232+
"size": 11.68949771689498
233233
},
234234
"tickangle": 0,
235235
"showline": false,
236236
"linecolor": null,
237237
"linewidth": 0,
238238
"showgrid": true,
239239
"gridcolor": "rgba(255,255,255,1)",
240-
"gridwidth": 0.66417600664176,
240+
"gridwidth": 0.66417600664176002,
241241
"zeroline": false,
242242
"anchor": "y",
243243
"title": {
244244
"text": "mpg",
245245
"font": {
246246
"color": "rgba(0,0,0,1)",
247247
"family": "",
248-
"size": 14.6118721461187
248+
"size": 14.611872146118724
249249
}
250250
},
251251
"hoverformat": ".2f"
@@ -259,8 +259,8 @@
259259
"type": "linear",
260260
"autorange": false,
261261
"range": [
262-
1.31745,
263-
5.61955
262+
1.3174499999999998,
263+
5.6195500000000003
264264
],
265265
"tickmode": "array",
266266
"ticktext": [
@@ -285,29 +285,29 @@
285285
"nticks": null,
286286
"ticks": "outside",
287287
"tickcolor": "rgba(51,51,51,1)",
288-
"ticklen": 3.65296803652968,
289-
"tickwidth": 0.66417600664176,
288+
"ticklen": 3.6529680365296811,
289+
"tickwidth": 0.66417600664176002,
290290
"showticklabels": true,
291291
"tickfont": {
292292
"color": "rgba(77,77,77,1)",
293293
"family": "",
294-
"size": 11.689497716895
294+
"size": 11.68949771689498
295295
},
296296
"tickangle": 0,
297297
"showline": false,
298298
"linecolor": null,
299299
"linewidth": 0,
300300
"showgrid": true,
301301
"gridcolor": "rgba(255,255,255,1)",
302-
"gridwidth": 0.66417600664176,
302+
"gridwidth": 0.66417600664176002,
303303
"zeroline": false,
304304
"anchor": "x",
305305
"title": {
306306
"text": "wt",
307307
"font": {
308308
"color": "rgba(0,0,0,1)",
309309
"family": "",
310-
"size": 14.6118721461187
310+
"size": 14.611872146118724
311311
}
312312
},
313313
"hoverformat": ".2f"
@@ -335,11 +335,11 @@
335335
"legend": {
336336
"bgcolor": "rgba(255,255,255,1)",
337337
"bordercolor": "transparent",
338-
"borderwidth": 1.88976377952756,
338+
"borderwidth": 1.8897637795275593,
339339
"font": {
340340
"color": "rgba(0,0,0,1)",
341341
"family": "",
342-
"size": 11.689497716895
342+
"size": 11.68949771689498
343343
}
344344
},
345345
"hovermode": "closest",
@@ -374,7 +374,7 @@
374374
"persistent": false,
375375
"dynamic": false,
376376
"selectize": false,
377-
"opacityDim": 0.2,
377+
"opacityDim": 0.20000000000000001,
378378
"selected": {
379379
"opacity": 1
380380
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /