@@ -100,7 +100,6 @@ gg2list <- function(p){
100
100
101
101
# # Extract data from built ggplots
102
102
built <- ggplot_build2(p )
103
-
104
103
# Get global x-range now because we need some of its info in layer2traces
105
104
ggranges <- built $ panel $ ranges
106
105
# Extract x.range
@@ -161,7 +160,9 @@ gg2list <- function(p){
161
160
names(ranks ) <- br
162
161
misc $ breaks [[sc $ aesthetics ]] <- ranks
163
162
}
163
+ misc $ trans [sc $ aesthetics ] <- sc $ trans $ name
164
164
}
165
+ reverse.aes <- names(misc $ trans )[misc $ trans == " reverse" ]
165
166
166
167
# # get gglayout now because we need some of its info in layer2traces
167
168
gglayout <- built $ panel $ layout
@@ -175,8 +176,16 @@ gg2list <- function(p){
175
176
df <- df [order(df $ order ),]
176
177
df $ order <- NULL
177
178
178
- misc $ prestats.data <- merge(built $ prestats.data [[i ]],
179
- gglayout [, c(" PANEL" , " plotly.row" , " COL" )])
179
+ prestats <- built $ prestats.data [[i ]]
180
+ # # scale_reverse multiples x/y data by -1, so here we undo that so
181
+ # # that the actual data can be uploaded to plotly.
182
+ replace.aes <- intersect(names(prestats ), reverse.aes )
183
+ for (a in replace.aes ){
184
+ prestats [[a ]] <- - 1 * prestats [[a ]]
185
+ }
186
+ misc $ prestats.data <-
187
+ merge(prestats ,
188
+ gglayout [, c(" PANEL" , " plotly.row" , " COL" )])
180
189
181
190
# Add global x-range info
182
191
misc $ prestats.data $ globxmin <- ggxmin
0 commit comments