@@ -151,30 +151,34 @@ detect_ggplot_kind <- function(gg) {
151151# Returns plot kind string or NULL
152152detect_kind_from_display_list <- function (dl ) {
153153 # Display list entries are lists where first element is the C function name
154- call_names <- vapply(dl , function (x ) {
155- if (is.list(x ) && length(x ) > 0 ) {
156- name <- x [[1 ]]
157- if (is.character(name )) name else " "
158- } else {
159- " "
160- }
161- }, character (1 ))
154+ call_names <- vapply(
155+ dl ,
156+ function (x ) {
157+ if (is.list(x ) && length(x ) > 0 ) {
158+ name <- x [[1 ]]
159+ if (is.character(name )) name else " "
160+ } else {
161+ " "
162+ }
163+ },
164+ character (1 )
165+ )
162166
163167 # Base graphics C functions to plot types
164- if (any(call_names == " C_plotHist" )) return (" histogram" )
165- if (any(call_names == " C_image" )) return (" image" )
166- if (any(call_names == " C_contour" )) return (" contour" )
167- if (any(call_names == " C_persp" )) return (" 3D surface" )
168- if (any(call_names == " C_filledcontour" )) return (" filled contour" )
169-
170- # Check for grid graphics (ggplot2, lattice)
171- if (any(grepl(" ^L_" , call_names ))) {
172- return (" grid" )
168+ if (any(call_names == " C_plotHist" )) {
169+ return (" histogram" )
173170 }
174-
175- # Check for base graphics
176- if (any(grepl(" ^C_" , call_names ))) {
177- return (" base" )
171+ if (any(call_names == " C_image" )) {
172+ return (" image" )
173+ }
174+ if (any(call_names == " C_contour" )) {
175+ return (" contour" )
176+ }
177+ if (any(call_names == " C_persp" )) {
178+ return (" 3D surface" )
179+ }
180+ if (any(call_names == " C_filledcontour" )) {
181+ return (" filled contour" )
178182 }
179183
180184 NULL
0 commit comments