@@ -2,7 +2,7 @@ magimageRGB<-function(x, y, R, G, B, saturation=1, zlim, xlim, ylim, add = FALSE
22 useRaster = TRUE , asp = 1 , magmap = TRUE , locut = 0.4 , hicut = 0.995 ,
33 flip = FALSE , range = c(0 ,1 ), type = " quan" , stretch = " asinh" ,
44 stretchscale = ' auto' , bad = range [1 ], clip = " " , axes = TRUE , frame.plot = TRUE ,
5- sparse = ' auto' , ... ){
5+ sparse = ' auto' , interact = FALSE , ... ){
66 dots = list (... )
77 dotskeepimage = c(' xaxs' , ' yaxs' , ' breaks' , ' oldstyle' )
88 if (length(dots )> 0 ){
@@ -88,25 +88,28 @@ magimageRGB<-function(x, y, R, G, B, saturation=1, zlim, xlim, ylim, add = FALSE
8888 rm(Ba )
8989 }
9090
91+ if (interact ){
92+ if (! requireNamespace(" plotly" , quietly = TRUE )){
93+ stop(' The plotly package is needed for this function to work. Please install it from CRAN.' , call. = FALSE )
94+ }
95+ if (! requireNamespace(" abind" , quietly = TRUE )){
96+ stop(' The abind package is needed for this function to work. Please install it from CRAN.' , call. = FALSE )
97+ }
98+ fig = plotly :: plot_ly(z = abind :: abind(t(R * 256 ), t(G * 256 ), t(B * 256 ), along = 3 ), type = " image" )
99+
100+ fig = plotly :: layout(
101+ p = fig ,
102+ xaxis = list (range = xlim , scaleanchor = " y" ), # Set x-axis limits and anchor to y-axis
103+ yaxis = list (range = ylim ) # Set y-axis limits
104+ )
105+
106+ print(fig )
107+ return (invisible (NULL ))
108+ }
109+
91110 z = matrix (1 : length(R ),dim(R )[1 ])
92111 col = rgb(R ,G ,B )
93112
94- # if(interact){
95- # if(!requireNamespace("plotly", quietly = TRUE)){
96- # stop('The plotly package is needed for this function to work. Please install it from CRAN.', call. = FALSE)
97- # }
98- # fig = plotly::plot_ly(x=x, y=y, z=z, type = "heatmap", colors = col, transpose=TRUE)
99- #
100- # fig = plotly::layout(
101- # p = fig,
102- # xaxis = list(range = xlim, scaleanchor = "y"), # Set x-axis limits and anchor to y-axis
103- # yaxis = list(range = ylim) # Set y-axis limits
104- # )
105- #
106- # print(fig)
107- # return(invisible(NULL))
108- # }
109-
110113 do.call(' image' ,c(list (x = x , y = y , z = z , zlim = zlim , xlim = xlim , ylim = ylim , col = col , add = add , useRaster = useRaster , axes = FALSE , asp = asp , xlab = ' ' , ylab = ' ' , main = ' ' ), dotsimage ))
111114 if (add == FALSE ){
112115 if (axes ){
0 commit comments