{"id":595,"date":"2014-04-21T15:16:36","date_gmt":"2014-04-21T20:16:36","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=595"},"modified":"2014-04-21T15:16:36","modified_gmt":"2014-04-21T20:16:36","slug":"image-plot-for-irregular-spatial-data","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2014\/04\/21\/image-plot-for-irregular-spatial-data\/","title":{"rendered":"Image plot for irregular spatial data."},"content":{"rendered":"<table style=\"color: #000000;\" summary=\"page for quilt.plot\" width=\"100%\">\n<tbody>\n<tr>\n<td>quilt.plot<\/td>\n<td align=\"right\">R Documentation<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"color: #000000;\">Image plot for irregular spatial data.<\/h2>\n<h3 style=\"color: #000000;\">Description<\/h3>\n<p style=\"color: #000000;\">Given a vector of z values associated with 2-d locations this function produces an image-like plot where the locations are discretized to a grid and the z values are coded as a color level from a color scale.<\/p>\n<h3 style=\"color: #000000;\">Usage<\/h3>\n<pre style=\"color: #000000;\">quilt.plot(x, y, z, nx = 64, ny = 64,nrow=nx, ncol=ny,  grid = NULL, \n                     add.legend=TRUE,add=FALSE,col=tim.colors(256),...)\n<\/pre>\n<h3 style=\"color: #000000;\">Arguments<\/h3>\n<table style=\"color: #000000;\" summary=\"R argblock\">\n<tbody>\n<tr valign=\"top\">\n<td><code>x<\/code><\/td>\n<td>A vector of the x coordinates of the locations -or- a a 2 column matrix of the x-y coordinates.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>y<\/code><\/td>\n<td>A vector of the y coordinates -or- if the locations are passed in x the z vector<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>z<\/code><\/td>\n<td>Values of the variable to be plotted.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>nx<\/code><\/td>\n<td>Number of grid boxes in x if a grid is not specified.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>ny<\/code><\/td>\n<td>Number of grid boxes in y.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>nrow<\/code><\/td>\n<td>Number of grid boxes in x.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>ncol<\/code><\/td>\n<td>Number of grid boxes in y.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>grid<\/code><\/td>\n<td>A grid in the form of a\u00a0<code>grid list<\/code>.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>add.legend<\/code><\/td>\n<td>If TRUE a legend color strip is added<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>add<\/code><\/td>\n<td>If FALSE add to existing plot.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>col<\/code><\/td>\n<td>Color scale for the image, the default is tim.colors \u2013 a pleasing spectrum.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><code>...<\/code><\/td>\n<td>arguments to be passed to the image.plot function<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"color: #000000;\">Details<\/h3>\n<p style=\"color: #000000;\">This function combines the discretization to an image by the function\u00a0<code>as.image<\/code>\u00a0and is then graphed by\u00a0<code>image.plot<\/code>. Locations that fall into the same grid box will have their z values averaged.<\/p>\n<p style=\"color: #000000;\">A similar function exists in the lattice package and produces good looking plots. The advantage of this fields version is that it uses the standard R graphics functions and is written in R code. Also, the aggregation to average values for z values in the same grid box allows for different choices of grids. If two locations are very close, separating them could result in very small boxes.<\/p>\n<p style=\"color: #000000;\">As always, legend placement is never completely automatic. Place the legend independently for more control, perhaps using<code>image.plot<\/code>\u00a0in tandem with\u00a0<code>split.screen<\/code>\u00a0or enlarging the plot margin See\u00a0<code>help(image.plot)<\/code>\u00a0for examples of this function and these strategies.<\/p>\n<h3 style=\"color: #000000;\">Author(s)<\/h3>\n<p style=\"color: #000000;\">D.Nychka<\/p>\n<h3 style=\"color: #000000;\">See Also<\/h3>\n<p style=\"color: #000000;\">as.image, image.plot, lattice, persp, drape.plot<\/p>\n<h3 style=\"color: #000000;\">Examples<\/h3>\n<pre style=\"color: #000000;\">data( ozone2)\n# plot 16 day of ozone data set\n\nquilt.plot( ozone2$lon.lat, ozone2$y[16,])\nUS( add=TRUE, col=\"grey\", lwd=2)\n\n#\n# and ... if you are fussy \n# do it again \n# quilt.plot( ozone2$lon.lat, ozone2$y[16,],add=TRUE)\n# to draw over the state boundaries. \n#\n\n### adding a common legend strip \"by hand\"\n## and a custom color table\n\ncoltab&lt;- two.colors( 256, middle=\"grey50\" )\n\npar( oma=c( 0,0,0,5)) # save some room for the legend\nset.panel(2,2)\nzr&lt;- range( ozone2$y, na.rm=TRUE)\n\nfor( k in 1:4){\nquilt.plot( ozone2$lon.lat, ozone2$y[15+k,], add.legend=FALSE,\n zlim=zr, col=coltab, nrow=40, ncol=40)\nUS( add=TRUE)\n}\npar( oma=c(0,0,0,1))\nimage.plot(zlim=zr,legend.only=TRUE, col=coltab)\n# may have to adjust number of spaces in oma to make this work.\n\n<\/pre>\n<h3 style=\"color: #000000;\">Results<\/h3>\n<pre style=\"color: #000000;\">R version 3.0.2 (2013-09-25) -- \"Frisbee Sailing\"\nCopyright (C) 2013 The R Foundation for Statistical Computing\nPlatform: x86_64-unknown-linux-gnu (64-bit)\n\nR is free software and comes with ABSOLUTELY NO WARRANTY.\nYou are welcome to redistribute it under certain conditions.\nType 'license()' or 'licence()' for distribution details.\n\nR is a collaborative project with many contributors.\nType 'contributors()' for more information and\n'citation()' on how to cite R or R packages in publications.\n\nType 'demo()' for some demos, 'help()' for on-line help, or\n'help.start()' for an HTML browser interface to help.\nType 'q()' to quit R.\n\n&gt; library(fields)\nLoading required package: spam\nSpam version 0.29-3 (2013-04-23) is loaded.\nType 'help( Spam)' or 'demo( spam)' for a short introduction \nand overview of this package.\nHelp for individual functions is also obtained by adding the\nsuffix '.spam' to the function name, e.g. 'help( chol.spam)'.\n\nAttaching package: 'spam'\n\nThe following objects are masked from 'package:base':\n\n    backsolve, forwardsolve\n\nLoading required package: maps\n&gt; png(filename=\"\/home\/oogasawa\/snapshot\/RGM3\/R_CC\/result\/fields\/quilt.plot.Rd_%03d_medium.png\", width=480, height=480)\n&gt; ### Name: quilt.plot\n&gt; ### Title: Image plot for irregular spatial data.\n&gt; ### Aliases: quilt.plot\n&gt; ### Keywords: hplot\n&gt; \n&gt; ### ** Examples\n&gt; \n&gt; \n&gt; data( ozone2)\n&gt; # plot 16 day of ozone data set\n&gt; \n&gt; quilt.plot( ozone2$lon.lat, ozone2$y[16,])\n&gt; US( add=TRUE, col=\"grey\", lwd=2)\n&gt; \n&gt; #\n&gt; # and ... if you are fussy \n&gt; # do it again \n&gt; # quilt.plot( ozone2$lon.lat, ozone2$y[16,],add=TRUE)\n&gt; # to draw over the state boundaries. \n&gt; #\n&gt; \n&gt; ### adding a common legend strip \"by hand\"\n&gt; ## and a custom color table\n&gt; \n&gt; coltab&lt;- two.colors( 256, middle=\"grey50\" )\n&gt; \n&gt; par( oma=c( 0,0,0,5)) # save some room for the legend\n&gt; set.panel(2,2)\nplot window will lay out plots in a 2 by 2 matrix \n&gt; zr&lt;- range( ozone2$y, na.rm=TRUE)\n&gt; \n&gt; for( k in 1:4){\n+ quilt.plot( ozone2$lon.lat, ozone2$y[15+k,], add.legend=FALSE,\n+  zlim=zr, col=coltab, nrow=40, ncol=40)\n+ US( add=TRUE)\n+ }\n&gt; par( oma=c(0,0,0,1))\n&gt; image.plot(zlim=zr,legend.only=TRUE, col=coltab)\n&gt; # may have to adjust number of spaces in oma to make this work.\n&gt; \n&gt;   \n&gt; \n&gt; \n&gt; \n&gt; \n&gt; dev.off()\nnull device \n          1 \n&gt;\n<\/pre>\n<p>&nbsp;<\/p>\n<table style=\"color: #000000;\">\n<tbody>\n<tr>\n<td><a style=\"color: #708090;\" href=\"http:\/\/rgm3.lab.nig.ac.jp\/RGM-files\/R_CC\/result\/fields\/quilt.plot.Rd_001_large.png\"><img decoding=\"async\" src=\"http:\/\/rgm3.lab.nig.ac.jp\/RGM-files\/R_CC\/result\/fields\/quilt.plot.Rd_001_medium.png\" alt=\"\" \/><\/a><a style=\"color: #708090;\" href=\"http:\/\/rgm3.lab.nig.ac.jp\/RGM-files\/R_CC\/result\/fields\/quilt.plot.Rd_002_large.png\"><img decoding=\"async\" src=\"http:\/\/rgm3.lab.nig.ac.jp\/RGM-files\/R_CC\/result\/fields\/quilt.plot.Rd_002_medium.png\" alt=\"\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>quilt.plot R Documentation Image plot for irregular spatial data. Description Given a vector of z values associated with 2-d locations this function produces an image-like&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":0,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}