在filled.contour函数中设置endscale

在filled.contour函数中设置endscale,r,R,我必须在不同时刻在世界地图上绘制一个物理变量。所以我得画很多情节,就像我要画多少时刻一样。问题是,我的例程默认设置了刻度的终点,这使得读取绘图变得困难。我想确定比例的末端,以便所有地块都有一个比例。这是我将重用的一段旧代码 require(reshape) require(mapdata) require(mapproj) df <- read.table('/media/Lacie2/dati/hy.dat',head=F) names(df) <- c("va

我必须在不同时刻在世界地图上绘制一个物理变量。所以我得画很多情节,就像我要画多少时刻一样。问题是,我的例程默认设置了刻度的终点,这使得读取绘图变得困难。我想确定比例的末端,以便所有地块都有一个比例。这是我将重用的一段旧代码

  require(reshape)
  require(mapdata)
  require(mapproj)
  df <- read.table('/media/Lacie2/dati/hy.dat',head=F)
  names(df) <- c("value", "x", "y")#, "t")
  dfc <- cast(df[ ,-4], x ~ y)
  mm<-as.matrix(dfc,ncol=480,nrow=241)
  filled.contour(x=seq(0,360,length.out=480),y=seq(-90,90,length.out=241),mm,
  color.palette = colorRampPalette(c("lightblue", "blue","violet", "black")),
  xlab = "Longitude (°)", ylab = "Latitude (°)",
  plot.axes = {axis(1); axis(2);            
  map('world2Hires',
  xlim = c(0, 360), 
  ylim = c(-90, 90), 
  add = T, col = "black")}
 )
require(重塑)
需要(地图数据)
需要(mapproj)

df如果只想打印最大颜色,则只需“修剪”传递给打印例程的

df$trimval <- pmin(df$value, 2)  
 # the range in the example below is roughly -4.5 to 4.5
因此,颜色范围在2处被最大化,并且2以上的所有值都以给定给2的颜色绘制。(我可能会提到,我曾尝试使用zlim,但结果并不像我想象的那样理想。)

require(reshape)
  require(mapdata)
  require(mapproj)
  df <- data.frame(value=rnorm( 480*241), x=seq(0,360,length.out=480),y=seq(-90,90,length.out=241) )
df$trimval <- pmin(df$value, 2)

  dfc <- cast(df[-1], x ~ y)
  mm<-as.matrix(dfc,ncol=480,nrow=241)
  filled.contour(x=seq(0,360,length.out=480),y=seq(-90,90,length.out=241),mm,
         color.palette = colorRampPalette(c("lightblue", "blue","violet", "black")),
         xlab = "Longitude (°)", ylab = "Latitude (°)",
         plot.axes = {axis(1); axis(2);            
                      map('world2Hires',
                      xlim = c(0, 360), 
                      ylim = c(-90, 90), 
                      add = T, col = "black")}
                )