@@ -199,14 +199,15 @@ plotSpatialData <- \() ggplot() + scale_y_reverse() + .theme
199199}
200200
201201# ' @importFrom ggplot2
202+ # ' scale_color_identity
202203# ' scale_x_continuous
203204# ' scale_x_continuous
204205# ' annotation_raster
205206.gg_i <- \(x , w , h , pal = NULL ) {
206207 lgd <- if (! is.null(pal )) list (
207208 guides(col = guide_legend(override.aes = list (alpha = 1 , size = 2 ))),
208209 scale_color_identity(NULL , guide = " legend" , labels = names(pal )),
209- geom_point(aes(col = foo ), data.frame (foo = pal ), x = 0 , y = 0 , alpha = 0 ))
210+ geom_point(aes(col = .data $ foo ), data.frame (foo = pal ), x = 0 , y = 0 , alpha = 0 ))
210211 list (lgd ,
211212 scale_x_continuous(limits = w ), scale_y_reverse(limits = rev(h )),
212213 annotation_raster(x , w [2 ],w [1 ], - h [1 ],- h [2 ], interpolate = FALSE ))
@@ -223,9 +224,9 @@ setMethod("plotImage", "SpatialData", \(x, i=1, j=1, k=NULL, ch=NULL, c=NULL, cl
223224 df <- .df_i(y , k , ch , c , cl )
224225 wh <- .get_wh(x , i , j )
225226 pal <- if (! .is_rgb(y ) && dim(y )[1 ] > 1 ) {
226- pal <- if (is.null(c )) .DEFAULT_COLORS else c
227227 nms <- channels(y )[idx <- .ch_idx(y , ch )]
228- setNames(pal [seq_along(idx )], nms )
228+ pal <- if (is.null(c )) .DEFAULT_COLORS else c
229+ pal <- pal [seq_along(idx )]; names(pal ) <- nms ; pal
229230 }
230231 .gg_i(df , wh $ w , wh $ h , pal )
231232})
0 commit comments