정확하게 이해하면 레이아웃이 par(mfrow=c(2, 1)
에 의해 정의 된 두 개의 플롯 옆에 전체 높이 범례를 플로팅하고 싶습니다.
이것을 달성하는 한 가지 방법은 두 개의 플롯을 생성 한 다음 par(new=FALSE)
을 설정하고 raster
을 다시 legend.only=TRUE
으로 플롯하는 것입니다.
library(rasterVis)
s <- stack(replicate(2, raster(matrix(runif(100), nc=10))))
levelplot(s, layout=c(1, 2), names.attr=c('One', 'Two'),
at=seq(0, 1, length.out=100),
par.strip.text=list(font=2, cex=1.2))
# Plotting titles for vertical colorkeys is a little fiddly...
grid::grid.text('Precipitation (mm)', rot=90, y=unit(0.5, "npc"),
x=unit(0.95, "npc"))
당신은 할 수 있습니다
library(raster)
r <- raster(matrix(runif(100), ncol=10))
# Set layout; ensure appropriate space at right for legend
par(mfrow=c(2, 1), mar=c(2, 3, 1, 3))
# Plot raster
plot(r, legend=FALSE, zlim=c(0, 1), las=1)
# Plot second object
plot(runif(10), runif(10), pch=21, cex=2, las=1,
bg=rev(terrain.colors(10)[sample(10, 10, replace=T)]))
# Revert to c(1, 1) layout and adjust legend margins
par(mfrow=c(1, 1), mar=c(2, 0, 1, 0), new=FALSE)
# Plot legend
plot(r, legend.only=TRUE, legend.shrink=1, legend.width=2, zlim=c(0, 1),
axis.args=list(at=pretty(0:1), labels=pretty(0:1)),
legend.args=list(text='Whatever', side=4, font=2, line=2.3))
당신이 일치하는 범위와 해상도로 여러 raster
객체를 플롯하는 경우, 당신은 RasterStack
방법이있다 rasterVis::levelplot
을 고려해 볼 수 있습니다로 패널 레이블을 억제하십시오. 당신은 전설이 두 행/플롯의 높이에 걸쳐하려는
levelplot(s, layout=c(1, 2),
col.regions=colorRampPalette(c('darkred', 'red3', 'orange2', 'orange',
'yellow', 'lightskyblue', 'steelblue3',
'royalblue3', 'darkblue')),
at=seq(0, 1, length.out=100), par.strip.text=list(cex=0),
scales=list(alternating=FALSE))
# Also demonstrating how to adjust fontface and size for legend title
grid::grid.text('Precipitation (mm)', y=unit(0.5, "npc"),
rot=90, x=unit(0.95, "npc"), gp=gpar(fontsize=14, font=2))
당신은 의미합니까 :및
col.regions
와 컬러 램프를 지정? 두 번째 줄에서 무엇을 계획하고 있습니까? 다른 '래스터'객체 (그렇다면 첫 번째 객체와 동일한 크기와 입체각을 가집니까?)? – jbaums