如何为R中的多个绘图创建通用图例?

如何为R中的多个绘图创建通用图例?,r,ggplot2,R,Ggplot2,如何为多个绘图创建通用图例?因为我已经绘制了多个绘图,但每个绘图本身都显示一个图例,就好像我要删除它并显示一个命令图例一样 我还想把xlim重命名为lon和ylim=lat。怎么可能在image.plot中呢 这是我的密码 set.panel() par(oma=c( 0,0,0,4)) # margin of 4 spaces width at right hand side set.panel( 2,2) # 2X2 matrix of plots

如何为多个绘图创建通用图例?因为我已经绘制了多个绘图,但每个绘图本身都显示一个图例,就好像我要删除它并显示一个命令图例一样

我还想把xlim重命名为lon和ylim=lat。怎么可能在image.plot中呢

这是我的密码

     set.panel()
     par(oma=c( 0,0,0,4)) # margin of 4 spaces width at right hand side
     set.panel( 2,2) # 2X2 matrix of plots

     # now draw all your plots using usual image command
    for (  k in 1:4){
   image.plot(lon, lat, pr2)
    plot(shape,add=TRUE)  
  image.plot(lon, lat, pr1)

      plot(shape,add=TRUE)

  }

    par(oma=c( 0,0,0,1))# reset margin to be much smaller.
   image.plot( legend.only=TRUE, zlim=c(0,2000),horizontal = TRUE) 
image.plot被诱骗到在旧设置的边界中打印

set.panel() # 
这是我的图像,显示了绘图:


你是否考虑使用GGPROT2和FACETHYLATH?这通常只绘制一个图例。因为我不习惯ggplot2?我会试试看。如果可能的话,任何人都可以修改上面的代码,这样对我来说就更容易了。