You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create.colourkey is a wrapper around lattice::draw.colorkey. We have set the parameter draw = TRUE which will print the key on whatever device/page is open or open a new device. I think this is a strange forced argument and should probably be an argument to create.colourkey with the default as draw = FALSE.
Look at the top of the heatmap. The colorkey is drawn on top when rendered via reprex but generally will often open a new device which generally means an extra file is created.
library(BoutrosLab.plotting.general);
#> Loading required package: lattice#> Loading required package: latticeExtra#> Loading required package: cluster#> Loading required package: hexbin#> Loading required package: grid#> #> Attaching package: 'BoutrosLab.plotting.general'#> The following object is masked from 'package:stats':#> #> dist
set.seed(13);
dat1<-matrix(rnorm(100), nrow=10, ncol=10);
dat2<-matrix(rnorm(100), nrow=10, ncol=10);
at<- seq(-3, 3, length.out=10);
p1<- create.heatmap(
dat1,
at=at,
clustering.method='none',
same.as.matrix=TRUE,
print.colour.key=FALSE
);
p2<- create.heatmap(
dat2,
at=at,
clustering.method='none',
same.as.matrix=TRUE,
print.colour.key=FALSE
);
# NOTE: This is a bug in create.colourkey. Opens a null device to write the output to# png(nullfile())colourkey<- create.colourkey(
x=dat1,
at=at,
colourkey.labels.cex=2.5,
placement= viewport(
just='center',
x=0.5,
y=1,
width=0.5,
height=0.1
)
);
# NOTE: This is a bug in create.colourkey. Close the null device we opened# dev.off();filename<- tempfile('example_shared_colourkey', fileext='.png');
create.multipanelplot(
plot.objects=list(p1, p2),
layout.width=2,
layout.height=1,
width=10,
height=6,
resolution=200,
legend=list(
bottom=list(
fun=colourkey
)
),
filename=filename
);
# To ensure that width/height are maintained by github/reprex# All this does it load and print the png we savedgrid::grid.raster(png::readPNG(filename))
create.colourkey
is a wrapper aroundlattice::draw.colorkey
. We have set the parameterdraw = TRUE
which will print the key on whatever device/page is open or open a new device. I think this is a strange forced argument and should probably be an argument tocreate.colourkey
with the default asdraw = FALSE
.Code in question: https://github.com/uclahs-cds/public-R-BoutrosLab-plotting-general/blob/main/R/create.colourkey.R#L168
See the workaround in the discussion: #139
Example
Look at the top of the heatmap. The colorkey is drawn on top when rendered via reprex but generally will often open a new device which generally means an extra file is created.
Created on 2023-07-20 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: