plotrix/0000755000176000001440000000000012132162470012001 5ustar ripleyusersplotrix/MD50000644000176000001440000003144712132162470012322 0ustar ripleyusers5c5d2a7128f48b8f83fcd9c230008539 *DESCRIPTION 2d3d571c7c3d7a9506be184a3dbbf0d5 *INDEX 7e42d50754b35d3589e4b532f3248b3d *NAMESPACE e31eeeb408b10157adf5a0db3711ff9e *NEWS 2c74abe5f355af8948fa9087f56959c9 *R/ablineclip.R 54f531a76de0b83b120f3f6a15108f4e *R/add.ps.R f29801ec7c9873adcade7ca525386eeb *R/addtable2plot.R 214995b84004be3bd42e51de47bf2105 *R/arctext.R fab32acaa7362918ba978d5ea0df6180 *R/axis.break.R 93b3e6deb1c3e93f5eef5d2d251c5f38 *R/axis.mult.R 9593c6eeb0582220e5868a57eb45de67 *R/barNest.R 94ebceeee14c8e482cb2b91858c4e6e6 *R/barlabels.R dfeba4a227e8ee602ea5e9658bd4b180 *R/barp.R 71bc84ef4d17fdaee2761e1bf48fc8af *R/battleship.plot.R 8cd0454ac9ccb08caf27867d61679552 *R/box.heresy.R c5ffa3ae37e01c6b6516bfa554963379 *R/boxed.labels.R 49aed74b2115a5e2d1e684abb9280f15 *R/brkdn.plot.R 1d844da3740e79baf61c4f896d4abcfc *R/brkdnNest.R 660723f580a00688b7c9a4a771cbdd68 *R/bumpchart.R f34b066424d85a26ff27d52dc0d9849a *R/centipede.plot.R 11f91483daa47b2d17ede65741fe6863 *R/clean.args.R f0103b3abf6e8faab8fd5812ba5f75ab *R/clplot.R 0d2a63fd54c0a7d77a5eb01353a180be *R/cluster.overplot.R 86952a8e0eff0913d83ed57387d0db35 *R/color.gradient.R f1dcc78b243e40ccd379fff2a1ca0590 *R/color.id.R 7c1e83994ce386af77d3da48b84e1f8d *R/color.legend.R 58d9be1d9b7bf8c7e3736df2b8afa109 *R/color.scale.R 07941d0c301f5cde9ca2da59e2600cdf *R/color.scale.lines.R f9e59f04b82e44e3d75e4d5ccf834197 *R/color2D.matplot.R b1a4683fbe6a0bd1859453c13b29b264 *R/corner.label.R 08b767b2cda37e28a744316c19bbea37 *R/count.overplot.R aa20dff9cb6508240f5ffe0b0f62e4d2 *R/cylindrect.R f484ea5befb6c1aeeb623b989d19a5a1 *R/dendrite.R 6ddb8ce458b2848f5fe22abb58e2f608 *R/dendroPlot.R 6ded5907b37e91f755f5c80c1bbd7b81 *R/diamondplot.R 35a13f6437c7dea5c85bda8639119bff *R/dispersion.R 260f6d56678e337a2466b63ce31e27dd *R/display.overplot.R e9e3f23cd4216bb463bf0993f2c604d8 *R/dotplot.mtb.R e7405994a30f3094ceae193a7c230c6b *R/draw.arc.R c1c0ae2c23bbb5899878ec35a8e0d15a *R/draw.circle.R ad6f95f688d5ba348298b2c71a2d7ede *R/draw.ellipse.R 1a1383ac27b34b7bfa800009969abfc0 *R/draw.radial.line.R f2c6b163b63a892bd0dfd4527a4c0f29 *R/drawNestedBars.R 386cd3bb808215ed21d4e2fe5591599e *R/ehplot.R 5690e7d7fc3795124df5b97a514b9305 *R/emptyspace.R be485fa47a06b433fa03396457693e93 *R/fan.plot.R bda3e7166adaeffc7b2d2a5686ad924f *R/feather.plot.R a1f6392682c991e547f3e4d82855b06f *R/floatpie.R 9d2cc070d1d3eb1c477e3374a42a036c *R/fullaxis.R 154fa8808c47c518de3769644525cdc2 *R/gantt.R c4df0ba725e7b54eccd94c46ea28f2f0 *R/gap.barplot.R a214e259cb5d5d430042f9335420e9a7 *R/gap.boxplot.R 830f67d6bde040606835b3807317ad63 *R/gap.plot.R 6949cc16ed4e73cc7358684e3ecab02b *R/getFigCtr.R 30440670860262b4287ee6de35cc675d *R/getIntersectList.R f62328458fae81303b94fbb7287175c6 *R/getMarginWidth.R 39c5a2ab540444944f48a55f990045e6 *R/gradient.rect.R 1f5757f389bb8be01efe273ee228f1bd *R/intersectDiagram.R 19800b6492dea784e4e1f10296bdc752 *R/kiteChart.R d4f22f0d1204a8436c58bef182abbeb4 *R/labbePlot.R 27982a3d5d4ea2879657c1dc56c9d070 *R/ladderplot.R 03cb2fbbe0aa70b2cd946262ebfb7813 *R/ladderplot.default.R b6b442151b22a4cd80d1956c24b091fc *R/legendg.R f88facb736d50a863537818e29e9098f *R/lengthKey.R 18a4b16260b37c922a70a6c439909b59 *R/makeIntersectList.R 83032771e287d63ea164fed14d1977f1 *R/maxEmptyRect.R 000018eff02dd539f58a75e49ebc3fb8 *R/multhist.R 0922537b9c49e3cc345347e46e7087b4 *R/multsymbolbox.R 53fc688fbe92d2f624a881d24a2745a0 *R/panes.R 52304cbd2133a98368562034e500fa70 *R/paxis3d.R 2b4741fbf98c46dbfdf94ede60352d4f *R/pie3D.R b9a64d1b0d4f890dbc817c1172fec476 *R/plotCI.R f10e1defb3c27cbd4459f322752389f0 *R/polygon.shadow.R 9ebc90e541363adca0d0b6bcb57f5a27 *R/pyramid.plot.R a6b7707ae6a4b7d83c7a2e5a653d751e *R/radial.pie.R 2bf47e3a77c497fa9d50d8fdd5cb2be1 *R/radial.plot.R 01aef229151813e543eb0aff5cce347f *R/radial.plot.labels.R f3ec3c43b07cc3f536c00da149714272 *R/radialtext.R 4dbb199a0884b4386e9da44d94047c7c *R/raw.means.plot.R f296be450c553a53120d278631ed4ec1 *R/rectFill.R da39dde9cdb82f81e5f3373588756c59 *R/rescale.R 0325ce82523cd877ba82c2d72c664ddc *R/revaxis.R 07d12fe4254d5ca97d9bc747aea667e2 *R/rm.plot2.R e761953480126b28a14326faa3cb680c *R/ruginv.R 39c9c4851da5b18766ba0d7764c55b46 *R/size_n_color.R 37823c945ea9eae7dfcd8d9f321b3da4 *R/sizeplot.R afda6e474f723e4cfa9b4ee3bd94cd2e *R/sizetree.R de129c7ed4e840767bbc911fb5256708 *R/smoothColors.R f1cf3329798b8c9a63871d5a6817ed2b *R/soil.texture.R 3da214e101fe17bebd16fb4649a666a8 *R/soil.texture.uk.R 86a9d362ca31c72a7e1be15add46b3a9 *R/spread.labels.R 45b113476e355fa9117ee728b8071f2a *R/spreadout.R d8630c1c4a7ce0332242e576cfc253dc *R/stackpoly.R 1476947622a48a0584ddc801394ebbdf *R/staircase.plot.R 7ad4f494e8a9f554e375aecafde6a816 *R/staxlab.R aee2eae39690917f1a489cb30122e977 *R/std.error.R 2f44a7f9539af99f2e91128142d315f0 *R/symbolbarplot.R baa253c7a54bcde2837f305ef2b492b4 *R/symbolbox.R 03fb7639ade1f0447d3630d247adfb12 *R/tab.title.R bc236570f35e46bfe800e093b22af61c *R/taylor.diagram.R 40ec91e2560e59d91e2d431a14866c03 *R/textbox.R 0e19d932405569d60b97d7fcca655786 *R/thigmophobe.R ed20aff50590ba744f276b1b4da0d3b8 *R/triax.R 2de4857cb9640475ebf293f5fc611c0b *R/twoord.plot.R 580be3c65f98df81f92dff1eff5e671c *R/twoord.stackplot.R 6b679551bcc23563f69f83ad38061c06 *R/vectorField.R cdcdd0cd94badf90f50620c73d576c0c *R/weighted.hist.R 481b3f85c721c582bc955c5059ba7c1e *R/windrose.R 52d0de3c89b6d90fe1e9157b0c76f291 *R/zoomInPlot.R 6c5b0047d50b0d071c9a8162c81ccb31 *data/death_reg.rda 8815e15e043fc4db1380b2409e438942 *data/soils.rda afe626471214438383c01dfcc2a12e10 *demo/00Index 7e8d45b04d011b30fb5fec189406467e *demo/plotrix.R b35ca73e819dbad59881960986301ef3 *inst/CITATION 2eeb957ab8eaca0916953227b019f794 *man/ablineclip.Rd 8472f4a3c2a3f4f844abb7d930e571e0 *man/add.ps.Rd bd9311e13d2913bdf631e1b5ac882d94 *man/addtable2plot.Rd 77d9c05552d05ad69f43722349f2fd3b *man/arctext.Rd be789402f5ae38868967b633a4eb3e32 *man/axis.break.Rd 54dbd1675f132a1f94c8dd2d804a4591 *man/axis.mult.Rd f4fba8a1f141a2c0c608192e6f0a7ba9 *man/barNest.Rd 0e0e139faa3faf1cbcd989eea0081a3b *man/barlabels.Rd 27e96e280a21a2a139f93650de65a24e *man/barp.Rd 13a6e1f637b62476def20eece0eded3d *man/battleship.plot.Rd 898f3abab9664c2f87d1a527f622e6ba *man/bin.wind.records.Rd 253fb0cd2b731457e490e6361e267209 *man/binciWl.Rd 7616ba496f078dbc5eb4f87a382c3e44 *man/binciWu.Rd 81d655e11085aa4ba6e8cc08323742c3 *man/box.heresy.Rd 4090f15478fe76d089ecd5d8a7a8bfd4 *man/boxed.labels.Rd 9823f0e0850a50fad057bc6ec814d0f7 *man/brkdn.plot.Rd 32a704671d1bcf783fc87d1fa6b7f638 *man/brkdnNest.Rd 1d64abef1dbc2b3641bfd90b96aa24f4 *man/bumpchart.Rd fdd959e735ce69d626bc683c7142a487 *man/categoryReshape.Rd e57177261b61c4ef3b8caf59dbda3091 *man/centipede.plot.Rd d6019ca90bd3aaaff4e63d9b55aff24c *man/clean.args.Rd afebae09379a8fd45edc6d21e5b37601 *man/clock24.plot.Rd dc4c200cb331f0490d5ce7ee0975534d *man/clplot.Rd 9649d68c6e8dabac22b9bab9b0e7cf6e *man/cluster.overplot.Rd 4108e162137a9083bd347763abbd63d7 *man/color.gradient.Rd 82cd4d974c60ea2828b06f81ee6239be *man/color.id.Rd b495073f04302bfd9ab7ddea8acca6e8 *man/color.legend.Rd f698f988d79f75fe558cfae14c53c305 *man/color.scale.Rd 45e516c607c3f1d3b7766595015d514c *man/color.scale.lines.Rd 30a327712a461da0821813370a4669b2 *man/color2D.matplot.Rd 51cd6dbe551abddadcf23f297b3fcef9 *man/corner.label.Rd 35453606f45c916c9b5f77020c3c3b0c *man/count.overplot.Rd b6bc308f4d4d62c4302afddb22666411 *man/cylindrect.Rd 403fec7cba6c01095a718a8503001bac *man/death_reg.Rd afb5f5ce1e6dbc78e8843df397f2f10c *man/dendroPlot.Rd 470583ce423fd9c05502a784d10114eb *man/diamondplot.Rd 6de3ee0dd113d0d186f6b64d8e3e650d *man/dispersion.Rd aae69bd515cac9d9ebdc8d89759b4029 *man/dotplot.mtb.Rd cb68dd72282e0a252f1689d786a10371 *man/draw.arc.Rd b24a1bf68bf35cfa467a648040003df5 *man/draw.circle.Rd e938b8d631000cd8dc6bd29deb24b361 *man/draw.ellipse.Rd 84e9daf9df6dc02632d28aad82fe552e *man/draw.radial.line.Rd c771ff20c909ba6d894c1dd73499b079 *man/draw.tilted.sector.Rd 62fddf568eadd5d8d0d38dd0265233ca *man/drawNestedBars.Rd e0cf4b49c5d11ec218ef091e3766443c *man/drawSectorAnnulus.Rd ff9c5395618869a65b04d6400b0cf2c4 *man/ehplot.Rd 4eb5b9648e8de073082c4d98fbb108af *man/emptyspace.Rd eda164aa9c06d80b10e758a871950649 *man/fan.plot.Rd 24342cd10fb35b3705b5c072bac27c6f *man/feather.plot.Rd 72ecc9d6ded89c4fa156bf59b7027cce *man/floating.pie.Rd ef0018a2314c3b5bf4d0e953ae036aed *man/fullaxis.Rd d4c458f97727e45e3deec31be4f67a18 *man/furc.Rd 5da354d8a9067af498d4af195ca69df3 *man/gantt.chart.Rd 4ac19f9bcfde71dd07c1326d6750b1ed *man/gap.barplot.Rd cfafb3f61e74fa03022d352f9fbe44b2 *man/gap.boxplot.Rd 5e734608333bf6a85619fc47fccc1ebe *man/gap.plot.Rd 2bfcd82c9e1bc208fade58833094861e *man/get.breaks.Rd df2bdbf654df6eab3ee5e96f846efc03 *man/get.gantt.info.Rd da679d8d83c5d75989816ea3f652e46f *man/get.segs.Rd 78207c9f46ee81fd350f075caf163c7c *man/get.soil.texture.Rd b38bf1ec364fc7e0d352d23949ff09d8 *man/get.triprop.Rd 59ce154c27e79c8655eb15c56abdb8fe *man/getFigCtr.Rd 1093b6fc68dc03a6ec675766b3b240a6 *man/getIntersectList.Rd 66e9bac85163b66dbe998ef0d6e23410 *man/getMarginWidth.Rd 81b41e59e8fdb64a7819ee5e5a1bad56 *man/get_axispos3d.Rd 165ea94083e1eaf7285da55db8094314 *man/gradient.rect.Rd 722a32a1697eac6a2d3d1b656c9e91a1 *man/hexagon.Rd 7895180e7374acb2b0c255421ba56e2f *man/intersectDiagram.Rd 85270b82b34b672df7f45cee5275488d *man/kiteChart.Rd 47d8e24c27f66b5d9bb08cec09bcee56 *man/labbePlot.Rd ea06b6e8b663a57af433a17c15721e2f *man/ladderplot.Rd 60e0e3228492e54cb7746d7bc6534022 *man/legendg.Rd 1087aef8002dcf7dd3c93309aa1e37fc *man/lengthKey.Rd 918f9ec4e06c9d8796e26c5fe0b2d39e *man/listDepth.Rd e108e4437e6471fa37c1ca95e96e3965 *man/makeDendrite.Rd 9d914bed93776844a53767ab40525a6f *man/makeIntersectList.Rd 4bf0a63a5ee0f446c2dd210ebd97b726 *man/maxEmptyRect.Rd 4bb726d76edd975db9258cd700783dcc *man/mtext3d.Rd 3c782a3683c1e4d09c2a178116f5421d *man/multhist.Rd a6b1e2596340a535c74848aeffe98833 *man/multsymbolbox.Rd 41c1c83e66a33d35bb0f48d9dfd68909 *man/oz.windrose.Rd 00585c01256159f892de1181dd9f63f3 *man/oz.windrose.legend.Rd f5f9a3f8fc633f528b69502756b032fe *man/panes.Rd e64d53c83bcdabd46565c0ebee38e23c *man/pasteCols.Rd df16d5a7e051f52e37eb2624bed0abf2 *man/paxis3d.Rd 024a5c644d2982a431cebaa10fd2131f *man/perspx.Rd eef697b49dae65a5df9bd465549963fb *man/pie.labels.Rd 6611561a873f31307e7de20c63a304f7 *man/pie3D.Rd 9209e3496d57207f40745b435e473b03 *man/pie3D.labels.Rd 4ebf99e8a0238ba7bacbcaa8af75f9e2 *man/plot.dendrite.Rd 94da9e98fdf1f64739b188fea1f021f6 *man/plotCI.Rd 205c4049d34feca3d7c8cd7c55648547 *man/polar.plot.Rd aacd4acbdc1275ecff45c6d962ae8f16 *man/polygon.shadow.Rd 8d1dc46509d56126301ed969bff3ed8c *man/print.brklist.Rd 192c0db4d2f6dc5182eb952f90efad97 *man/propbrk.Rd d3979b4cb2e49006ebd6bc1e2c795fb9 *man/psegments3d.Rd a239386f59c013ebc0e4bf9fcabc5747 *man/ptext3d.Rd a2917cb026003446a0d5a93ac1c67a7e *man/pyramid.plot.Rd 4e8e4e5ada5259a8704e0bb3f4d6e94a *man/radial.grid.Rd 1f6c4490cc3851db21fe173860c341ef *man/radial.pie.Rd fb2f9e10582c0f691a2098f482a175a3 *man/radial.plot.Rd 7d2279ed398dc0600793cb09d86a71bc *man/radial.plot.labels.Rd 9e52803106c4336f54b18549a02a99d2 *man/radialtext.Rd 4dde950ac199488ec25611c95b010d31 *man/raw.means.plot.Rd 12483f6f1bca2cc5501598e3e4a98aed *man/rectFill.Rd c4f2c015fcd5a98581ef7859a1640e5a *man/rescale.Rd 806b61300d1880bdd26a85011d845714 *man/revaxis.Rd e707694b2762db46d4e938f3383b5577 *man/ruginv.Rd 416ae0d78cb97e3fa1056070e91858c9 *man/size_n_color.Rd f2586a13028c3884bdc4335610c67dc9 *man/sizeplot.Rd 9ca9c876993f87ec6dc5520e31dedf70 *man/sizetree.Rd 554e180d9da267bedc3ad04b2bd6f4aa *man/sliceArray.Rd 1b6f61faec620b2a1cc2b4c1b95fcc7e *man/smoothColors.Rd 22fb9a2d6c8680cabf57f8d0caf203a5 *man/soil.texture.Rd 56b0e186a2d31d3f9c4f5a38f54540df *man/soil.texture.uk.Rd 1538a56e8001fbdac5bc6fe59989cb75 *man/soils.Rd 94621600224164995f082b46963b8f87 *man/spread.labels.Rd 68ecac1afb03f4f889768018295f8a2c *man/spreadout.Rd ccc9108bc93acce70abff100c678aa44 *man/stackpoly.Rd 9c398b8547a4202590065791ba3ce8f9 *man/staircase.plot.Rd 33988f78aacfa54f729335552a96eae3 *man/staxlab.Rd 40286c6064e6b9e29ba37f06058b89df *man/std.error.Rd c02fd1aaeea9441f1b8e8790cadd3d58 *man/sumDendrite.Rd e7999e03fb6b204de02abb047fe420e2 *man/sumbrk.Rd ef9a85ac60b082897b7a8c3a8c9892ee *man/symbolbarplot.Rd ae8f69cda8160327316c915a992151c9 *man/symbolbox.Rd d9f79a0e522fcb9a4d1af0873723a412 *man/tab.title.Rd f4ae745d812b143ce14ba718581e2a2c *man/taylor.diagram.Rd 78e9845825dfde81846bdca59142da45 *man/textbox.Rd 435910f39b3e5a2b60fb8906aa45e390 *man/thigmophobe.Rd 88d920d3e1d02345f92f2b2f283be090 *man/thigmophobe.labels.Rd ac5071d4a906c8d08c62d24c1059d548 *man/triax.abline.Rd 5fc757905ff2fb69baab63abdba3d364 *man/triax.fill.Rd ef26303ff7d7fca80a4e6aa6a4faface *man/triax.frame.Rd fc7ea4a90434e5b05a28e1be6b00c0ef *man/triax.plot.Rd cae9faa9c12feab91f4b7e3a03eb02f3 *man/triax.points.Rd 0d93b11db81f5495d1bd19d1154fa05a *man/twoord.plot.Rd 4b0b895d4f207d31f039876eee86c956 *man/twoord.stackplot.Rd 517c4cd06972f8ccde88ccd063e40dd1 *man/valid.n.Rd fec04eee273289a8f3cc6c1ab2c74741 *man/vectorField.Rd da967637efe92ac080392fe7a08c8639 *man/weighted.hist.Rd 2ac8767af5192740723f42558d4486e9 *man/zoomInPlot.Rd plotrix/man/0000755000176000001440000000000012132136161012552 5ustar ripleyusersplotrix/man/zoomInPlot.Rd0000755000176000001440000000350011424521756015167 0ustar ripleyusers\name{zoomInPlot} \alias{zoomInPlot} \title{ Display a plot with a rectangular section expanded in an adjacent plot } \description{ Display one plot on the left half of a device and an expanded section of that plot on the right half of the device with connecting lines showing the expansion. } \usage{ zoomInPlot(x,y=NULL,xlim=NULL,ylim=NULL,rxlim=xlim,rylim=ylim,xend=NA, zoomtitle=NULL,titlepos=NA,...) } \arguments{ \item{x,y}{numeric data vectors. If \samp{y} is not specified, it is set equal to \samp{x} and \samp{x} is set to \samp{1:length(y)}.} \item{xlim,ylim}{Limits for the initial plot.} \item{rxlim,rylim}{Limits for the expanded plot. These must be within the above.} \item{xend}{Where to end the segments that indicate the expansion. Defaults to just left of the tick labels on the left ordinate.} \item{zoomtitle}{The title of the plot, display in the top center.} \item{titlepos}{The horizontal position of the title in user units of the zoomed plot.} \item{...}{additional arguments passed to \samp{plot}.} } \details{ \samp{zoomInPlot} sets up a two column layout in the current device and calls \samp{plot} to display a plot in the left column. It then draws a rectangle corresponding to the \samp{rxlim} and \samp{rylim} arguments and displays a second plot of that rectangle in the right column. It is currently very simple and will probably become more flexible in future versions. It just has. If \samp{rxlim} is set to NA, \samp{locator} will be called and the user can define the zoomed rectangle by clicking on each corner. This is a shameless ripoff of a suggestion by Greg Snow on the help list. Thanks, Greg. } \value{nil} \author{Jim Lemon} \seealso{\link{plot}} \examples{ zoomInPlot(rnorm(100),rnorm(100),rxlim=c(-1,1),rylim=c(-1,1), zoomtitle="Zoom In Plot",titlepos=-1.5) } \keyword{misc} plotrix/man/weighted.hist.Rd0000755000176000001440000000447111774767523015647 0ustar ripleyusers\name{weighted.hist} \alias{weighted.hist} \title{ Display a weighted histogram } \description{ Calculate the counts of the weighted values in specified bins and optionally display either a frequency or density histogram. } \usage{ weighted.hist(x,w,breaks="Sturges",col=NULL,plot=TRUE, freq=TRUE,ylim,ylab=NULL,xaxis=TRUE,...) } \arguments{ \item{x}{A vector of numeric values} \item{w}{A vector of weights at least as long as x.} \item{breaks}{The endpoints of the ranges into which to count the weighted values.} \item{col}{An optional vector of colors for the bars of the histogram.} \item{plot}{Whether to plot a histogram.} \item{freq}{Whether to plot counts or densities.} \item{ylim}{The limits of the plot ordinate.} \item{ylab}{Label for the ordinate.} \item{xaxis}{Whether to display the default x axis.} \item{...}{Additional arguments passed to \link{barplot}.} } \details{ \samp{weighted.hist} calculates the weighted counts of values falling into the ranges specified by \samp{breaks}. Instead of counting each value as 1, it counts the corresponding value in \samp{w} (the weight). \samp{breaks} may be specified by a monotonically increasing vector of numbers that are interpreted as the endpoints of the ranges, a single number representing the number of ranges desired or the name of the function to calculate the ranges (see \link{hist}). If a vector of numbers is passed that does not include all values in \samp{x}, the user is warned. If the ranges are not equal, a warning will be displayed if \samp{freq} is TRUE or the heights of the bars will be adjusted to display areas approximately equal to the counts if \samp{freq} is FALSE. } \value{A list containing: breaks - The endpoints of the intervals counts - The weighted counts density - The weighted counts divided by their sum. mids - The midpoints of the intervals and the bars displayed. xname - the name of \samp{x}. equidist - Whether the intervals differ by less than the total range/1000. } \author{Jim Lemon and Hadley Wickham - thanks to Ben Graf for asking for a custom x axis option} \seealso{\link{hist}} \examples{ testx<-sample(1:10,300,TRUE) testw<-seq(1,4,by=0.01) weighted.hist(testx,testw,breaks=1:10,main="Test weighted histogram") } \keyword{misc} plotrix/man/vectorField.Rd0000755000176000001440000000461511770564515015337 0ustar ripleyusers\name{vectorField} \alias{vectorField} \title{Display magnitude/direction vectors} \description{Display magnitude/direction vectors as arrows on an existing plot.} \usage{ vectorField(u,v,xpos=NA,ypos=NA,scale=1,headspan=0.1, vecspec=c("lonlat","rad","deg"),col=par("fg")) } \arguments{ \item{u,v}{x (longitude) and y (latitude) offsets OR orientation and magnitude in either radians or degrees. See details.} \item{xpos,ypos}{The centers of the vectors in user units.} \item{scale}{The proportion of each cell that the maximal vector will fill. See details.} \item{headspan}{The extent of the heads of the arrows as a proportion of cell size.} \item{vecspec}{How the vectors are described. See details} \item{col}{Color(s) for the arrows.} } \value{ nil } \details{ \samp{vectorField} displays arrows on an existing plot. Each arrow is specified by a position on the plot \samp{xpos,ypos} and either x/y offsets or orientation and magnitude. The default is x/y offsets, and the user must specify whether radians or degrees are used if the orientation/magnitude option is used. If the first four arguments are matrices, there must be no missing values. If these arguments are vectors, the calculation of the scaling of the magnitudes and length of the arrowheads may be slightly different. } \author{Jim Lemon (original code by Robin Hankin and Brian Ripley)} \seealso{\link{arrows}} \examples{ \dontrun{ # this requires the maps package, and just wouldn't pass check require(maps) map("world",xlim=c(110,155),ylim=c(-40,-10)) par(xpd=TRUE) text(132,-5,"Approximate magnetic deviation - Australia",cex=1.5) par(xpd=FALSE) long<-rep(seq(117.5,152.5,by=5),6) lat<-rep(c(-12.5,-17.5,-22.5,-27.5,-32.5,-37.5),each=8) # just show the direction, don't have a magnitude difference mag<-rep(1,48) devdeg<-c(110,98,85,65,65,65,65,65, 115,100,90,80,72,66,63,55, 130,100,90,82,72,67,62,54, 122,111,95,86,70,67,56,48, 118,116,110,87,74,68,62,45, 128,115,107,90,78,66,53,45) vectorField(devdeg,mag,long,lat,scale=0.7,vecspec="deg") } # do a magnitude/direction plot with radians plot(1:10,type="n",main="Random vectors") mag<-runif(100)+1 dir<-runif(100)*2*pi xpos<-rep(1:10,10) ypos<-rep(1:10,each=10) vectorcol<-sample(colors(),100) vectorField(dir,mag,xpos,ypos,scale=0.8,vecspec="rad",col=vectorcol) } \keyword{misc} plotrix/man/valid.n.Rd0000755000176000001440000000101311463771670014412 0ustar ripleyusers\name{valid.n} \alias{valid.n} \title{ Find the number of valid (not NA) values } \description{ Finds the number of valid (not NA) or total values in an object. } \usage{ valid.n(x,na.rm=TRUE) } \arguments{ \item{x}{An object.} \item{na.rm}{Whether to count all values (FALSE) or only those not NA.} } \details{ \samp{valid.n} finds the number of valid values of the object if \samp{na.rm=TRUE}. } \value{The number of valid values or the length of the object.} \author{Jim Lemon} \keyword{misc} plotrix/man/twoord.stackplot.Rd0000755000176000001440000000560511364030210016365 0ustar ripleyusers\name{twoord.stackplot} \alias{twoord.stackplot} \title{Multiple (stack) plot with two ordinates} \description{ Two set of data are plotted on two different ordinate scales. } \usage{ twoord.stackplot(lx, rx, ldata, rdata, lcol, rcol, ltype, rtype, border, rylab, lylab, xlab, ..., incrylim=NULL, halfwidth=0.4, leftfront=FALSE, mar = c(5, 4, 4, 4)) } \arguments{ \item{lx,rx}{x-values for left/right data.} \item{ldata,rdata}{data on the left/right y-axes.} \item{lcol, rcol}{colors to be used for left/right data.} \item{ltype, rtype}{line types to be used for left/right data, see details.} \item{border}{color for the border of barplot} \item{rylab,lylab}{labels for the left/right y-axes.} \item{xlab}{labels for the x-axis.} \item{...}{further arguments to be passed to \samp{plot}.} \item{incrylim}{a number to increase the limits of y-axes.} \item{halfwidth}{half the width of the bars in user units. The bars are centered on successive integers if no x values are supplied} \item{leftfront}{if \samp{TRUE}, plot the left data on the front layer.} \item{mar}{optional margin adjustment, defaults to c(5,4,4,4).} } \details{ \samp{twoord.stackplot} works in the same way as \samp{twoord.plot} on which it is heavily inspired. The functions let the user plot multiple curve/point or bar plots on the same graph with two different axes. The line type can be one of the following \samp{"l"} for lines, \samp{"p"} for points, \samp{"b"} for both points and line, \samp{"o"} for overplotted, \samp{"bar"} for barplot. } \value{ nil } \seealso{\link{twoord.plot}} \author{ Christophe Dutang } \examples{ # plot data # time <- 0:25 A <- 1+1/2*sin(time/2) B <- A + rnorm(length(A), sd=1/10) B <- B + rnorm(length(A), sd=1/10) sizeA <- floor(450*(1 + 1/4*sin(time/2+2))*(1+.1)) sizeB <- 1000-sizeA C <- (A*sizeA + B*sizeB)/(sizeA+sizeB) #typical usage # twoord.stackplot(lx=time, rx=time, ldata=cbind(sizeA, sizeB), rdata=cbind(A, B, C), lcol=c("grey80", "white"), rcol=c("blue", "red","black"), ltype="bar", rtype=c("l","p","o"), border="grey80", lylab="Size", rylab="A,B,C", xlab="Time", main="a plot", incrylim=2/100) #add a legend # par(xpd=TRUE) #extend the area of plotting par(new=TRUE) #to add new graph "layers" plot(0:1, 0:1, type="n", xlab="",ylab="", axes=FALSE) #redo the x/y limits #first legend legend(-0.18, 1.2, leg=c("Size A", "Size B"), fill=c("grey80", "white")) #second legend legend(.97, -0.08, leg=c("A", "B", "C"), col=c("blue", "red","black"), pch=c(NA, 19, 19), lty=c(1,NA,1)) par(xpd=FALSE, new=FALSE) #default setting #reverse the order of plotting twoord.stackplot(lx=time, rx=time, ldata=cbind(sizeA, sizeB), rdata=cbind(A, B, C), lcol=c("grey80", "white"), rcol=c("blue", "red","black"), ltype="bar", rtype=c("l","p","o"), border="grey80", lylab="Size", rylab="A,B,C", xlab="Time", main="a plot", incrylim=2/100, leftfront=TRUE) } \keyword{misc} plotrix/man/twoord.plot.Rd0000755000176000001440000001236211554260646015360 0ustar ripleyusers\name{twoord.plot} \alias{twoord.plot} \title{ Plot with two ordinates } \description{ Two sets of values are displayed on the same plot with different ordinate scales on the left and right. } \usage{ twoord.plot(lx,ly,rx,ry,data=NULL,xlim=NULL,lylim=NULL,rylim=NULL, mar=c(5,4,4,4),lcol=1,rcol=2,xlab="",ylab="",rylab="",lpch=1,rpch=2, type="b",xtickpos=NULL,xticklab=NULL,halfwidth=0.4,axislab.cex=1,...) } \arguments{ \item{lx,ly,rx,ry}{y and optional x values for the plot} \item{data}{an optional data frame from which to obtain the above values} \item{xlim}{optional x limits as in \samp{plot}} \item{lylim,rylim}{optional y limits for the left and right axes respectively} \item{mar}{optional margin adjustment, defaults to \samp{c(5,4,4,4)}} \item{lcol,rcol}{colors to distinguish the two sets of values} \item{xlab,ylab}{axis labels as in \samp{plot}} \item{rylab}{label for the right axis} \item{lpch,rpch}{plot symbols to distinguish the two sets of values} \item{type}{as in \samp{plot}} \item{xtickpos}{Optional positions for x-axis tick labels.} \item{xticklab}{Optional labels for x-axis. Useful for things like dates.} \item{halfwidth}{Half the width of the bars in user units. The bars are centered on successive integers if no \samp{x} values are supplied.} \item{axislab.cex}{Character expansion for the axis labels and tick labels.} \item{...}{additional arguments passed to \samp{plot}.} } \value{nil} \details{ \samp{twoord.plot} automates the process of displaying two sets of values that have different ranges on the same plot. It is principally useful in illustrating some relationship between the values across the observations. It is assumed that the \samp{lx} and \samp{rx} values are at least adjacent, and probably overlapping. It is best to pass all the arguments \samp{lx, ly, rx, ry}, but the function will attempt to substitute sensible x values if one or two are missing. If at least one of the \samp{type} arguments is "bar", bars will be plotted instead of points or lines. It is best to plot the bars first (i.e. relative to the left axis) if the other type is points or lines, as the bars will usually obscure at least some of the points or lines. Using NA for the color of the bars will partially correct this. If both types are to be bars, remember to pass somewhat different x values or the bars will be overlaid. Note that more values can be added to the plot using \samp{points} or \samp{lines}, but remember that these will be plotted relative to the right ordinate, and the \samp{rylim} argument may need to be set so that more extreme points in subsequent series will be within the plot area. } \note{ There are many objections to the use of plots with two different ordinate scales, and some of them are even sensible and supported by controlled observation. Many of the objections rest on assertions that the spatial arrangement of the values plotted will override all other evidence. Here are two: The viewer will assume that the vertical position of the data points indicates a quantitative relationship. To some extent. It is probably not a good idea to have the spatial relationship of the points opposed to their numerical relationship. That is to say, if one set of values is in the range of 0-10 and the other 20-100, it is best to arrange the plot so that the latter values are not plotted below the former. The viewer will assume that an intersection of lines indicates an intersection of values. If the visual elements representing values can be arranged to avoid intersections, so much the better. Many people have no trouble distinguishing which visual elements are linked to which axis as long as they are both coded similarly, usually with colors and/or symbols. In the special case where there is an underlying relationship between the two such as the probability of that value occurring under some conditions, it may help to mark the point(s) where this occurs. It may be useful to consider \samp{gap.plot} as an alternative. } \author{Jim Lemon (thanks to Christophe Dutang for the idea of using bars and lines in the same plot, Clair Crossupton for pointing out that dates on the x-axis weren't very good and Jacob Kasper for the axis character expansion.)} \seealso{\link{plot}} \examples{ twoord.plot(2:10,seq(3,7,by=0.5)+rnorm(9), 1:15,rev(60:74)+rnorm(15),xlab="Sequence", ylab="Ascending values",rylab="Descending values", main="Plot with two ordinates - points and lines") twoord.plot(2:10,seq(3,7,by=0.5)+rnorm(9), 1:15,rev(60:74)+rnorm(15),xlab="Sequence", ylab="Ascending values",rylab="Descending values", main="Plot with two ordinates - bars on the left", type=c("bar","l"),lcol=3,rcol=4) twoord.plot(2:10,seq(3,7,by=0.5)+rnorm(9), 1:15,rev(60:74)+rnorm(15),xlab="Sequence", ylab="Ascending values",rylab="Descending values", main="Plot with two ordinates - bars on the right", type=c("b","bar"),lcol=2,rcol=NA,halfwidth=0.2) # histogram with density curve overlaid xhist<-hist(rnorm(100),plot=FALSE) xdens<-dnorm(seq(-2,2,by=0.05)) twoord.plot(xhist$mids,xhist$counts,seq(-2,2,by=0.05), xdens,type=c("bar","l"),lcol=4,rcol=2,ylab="Counts", rylab="Density",main="Histogram and density curve", halfwidth=0.2,lylim=c(0,25),rylim=c(0,0.45)) } \keyword{misc} plotrix/man/triax.points.Rd0000755000176000001440000000360211324077460015517 0ustar ripleyusers\name{triax.points} \alias{triax.points} \title{Triangle plot points} \description{ Display points on a triangle plot. } \usage{ triax.points(x,show.legend=FALSE,label.points=FALSE,point.labels=NULL, col.symbols=par("fg"),pch=par("pch"),bg.symbols=par("bg"),cc.axes=FALSE,...) } \arguments{ \item{x}{Matrix or data frame where each row is three proportions or percentages that must sum to 1 or 100 respectively.} \item{show.legend}{Logical - whether to display a legend.} \item{label.points}{Logical - whether to call \samp{thigmophobe.labels} to label the points.} \item{point.labels}{Optional labels for the points and/or legend.} \item{col.symbols}{Color of the symbols representing each value.} \item{pch}{Symbols to use in plotting values.} \item{bg.symbols}{Background color for plotting symbols.} \item{cc.axes}{Clockwise or counterclockwise axes and ticks.} \item{...}{Additional arguments passed to \samp{points}.} } \details{ In order for \samp{triax.points} to add points to an existing plot, the argument \samp{no.add} in the initial call to \samp{triax.plot} must be set to \samp{FALSE}. Failing to do this will result in the points being plotted in the wrong places. It is then up to the user to call \samp{par} as in the example below to restore plotting parameters altered during the triangle plot. \samp{triax.points} displays each triplet of proportions or percentages as a symbol on the triangle plot. Unless each triplet sums to 1 (or 100), they will not plot properly and \samp{triax.points} will complain appropriately. } \value{A list of the \samp{x,y} positions plotted.} \author{Jim Lemon} \seealso{\link{triax.plot},\link{thigmophobe.labels}} \examples{ data(soils) triax.return<-triax.plot(soils[1:10,], main="Adding points to a triangle plot",no.add=FALSE) triax.points(soils[11:20,],col.symbols="green",pch=3) par(triax.return$oldpar) } \keyword{misc} plotrix/man/triax.plot.Rd0000755000176000001440000000742011503602674015163 0ustar ripleyusers\name{triax.plot} \alias{triax.plot} \title{Triangle plot} \description{ Display a triangle plot with optional grid. } \usage{ triax.plot(x=NULL,main="",at=seq(0.1,0.9,by=0.1), axis.labels=NULL,tick.labels=NULL,col.axis="black",cex.axis=1,cex.ticks=1, align.labels=TRUE,show.grid=FALSE,col.grid="gray",lty.grid=par("lty"), cc.axes=FALSE,show.legend=FALSE,label.points=FALSE,point.labels=NULL, col.symbols="black",pch=par("pch"),mar=c(5,2,4,2),no.add=TRUE,...) } \arguments{ \item{x}{Matrix where each row is three proportions or percentages that must sum to 1 or 100 respectively.} \item{main}{The title of the triangle plot. Defaults to nothing.} \item{at}{The tick positions on the three axes.} \item{axis.labels}{Labels for the three axes in the order left, right, bottom. Defaults to the column names.} \item{tick.labels}{The tick labels for the three axes as a list with three components l, r and b (left, right and bottom). Defaults to argument \samp{at} (proportions).} \item{col.axis}{Color of the triangular axes, ticks and labels.} \item{cex.axis}{Character expansion for axis labels.} \item{cex.ticks}{Character expansion for the tick labels.} \item{align.labels}{Logical - whether to align axis and tick labels with the axes.} \item{show.grid}{Whether to display grid lines at the ticks.} \item{col.grid}{Color of the grid lines. Defaults to gray.} \item{lty.grid}{Type of line for the grid.} \item{cc.axes}{Whether axes and axis ticks should be clockwise or counterclockwise.} \item{show.legend}{Logical - whether to display a legend.} \item{label.points}{Logical - whether to call \samp{thigmophobe.labels} to label the points.} \item{point.labels}{Optional labels for the points and/or legend.} \item{col.symbols}{Color of the symbols representing each value.} \item{pch}{Symbols to use in plotting values.} \item{mar}{Margins for the triangle plot.} \item{no.add}{Whether to restore the previous plotting parameters (\samp{TRUE}) or leave them, allowing more points to be added.} \item{...}{Additional arguments passed to \samp{points}.} } \details{ \samp{triax.plot} displays a triangular plot area on which proportions or percentages are displayed. A grid or legend may also be displayed. } \note{ A three axis plot can only properly display one or more sets of three proportions that each sum to 1 (or percentages that sum to 100). Other values may be scaled to proportions (or percentages), but unless each set of three sums to 1 (or 100), they will not plot properly and \samp{triax.points} will complain appropriately. Note also that \samp{triax.plot} will only display properly in a square plot, which is forced by \samp{par(pty="s")}. In case the user does want to plot values with different sums, the axis tick labels can be set to different ranges to accomodate this. \samp{triax.points} will still complain, but it will plot the values. If planning to add points with \samp{triax.points} call \samp{triax.plot} with \samp{no.add=FALSE} and restore plotting parameters after the points are added. } \value{ A list containing \samp{xypos} (the \samp{x,y} positions plotted) and \samp{oldpar} (the plotting parameters at the time \samp{triax.plot} was called). } \author{ Jim Lemon - thanks to Ben Daughtry for the info on counterclockwise axes. } \seealso{ \link{triax.points}, \link{triax.abline}, \link{thigmophobe.labels} } \examples{ data(soils) triax.plot(soils[1:10,],main="DEFAULT") triax.plot(soils[1:10,],main="PERCENTAGES (Counterclockwise axes)", tick.labels=list(l=seq(10,90,by=10),r=seq(10,90,by=10),b=seq(10,90,by=10)), pch=3,cc.axes=TRUE) triax.return<-triax.plot(soils[1:6,],main="GRID AND LEGEND", show.grid=TRUE,show.legend=TRUE,col.symbols=1:6,pch=4) # triax.plot changes a few parameters par(triax.return$oldpar) } \keyword{misc} plotrix/man/triax.frame.Rd0000755000176000001440000000305111361052260015263 0ustar ripleyusers\name{triax.frame} \alias{triax.frame} \title{Triangle plot frame} \description{ Display a three axis frame with optional grid. } \usage{ triax.frame(at=seq(0.1,0.9,by=0.1),axis.labels=NULL, tick.labels=NULL,col.axis="black",cex.axis=1,cex.ticks=1, align.labels=TRUE,show.grid=FALSE,col.grid="gray",lty.grid=par("lty"), cc.axes=FALSE) } \arguments{ \item{at}{The tick positions on the three axes.} \item{axis.labels}{Labels for the three axes in the order bottom, right left. Defaults to the column names.} \item{tick.labels}{The tick labels for the axes. Defaults to argument \samp{at} (proportions).} \item{col.axis}{Color of the triangular axes, ticks and labels.} \item{cex.axis}{Character expansion for axis labels.} \item{cex.ticks}{Character expansion for the tick labels.} \item{align.labels}{Logical - whether to align axis and tick labels with the axes.} \item{show.grid}{Whether to display grid lines at the ticks.} \item{col.grid}{Color of the grid lines. Defaults to gray.} \item{lty.grid}{Type of line for the grid.} \item{cc.axes}{Whether to align the axes clockwise or counterclockwise.} } \details{ \samp{triax.frame} displays a triangular plot area on which proportions or percentages may be displayed. An optional grid may also be displayed. If \samp{cc.axes} is TRUE, both the axes and axis ticks will be in reverse order. } \value{nil} \author{Jim Lemon} \seealso{\link{triax.points},\link{triax.abline},\link{triax.fill}} \examples{ triax.plot(main="DEFAULT") triax.plot(main="Clockwise axes",cc.axes=TRUE) } \keyword{misc} plotrix/man/triax.fill.Rd0000755000176000001440000000261611344072022015124 0ustar ripleyusers\name{triax.fill} \alias{triax.fill} \title{Triangle plot fill} \description{ Fill a triangle plot with smaller triangles. } \usage{ triax.fill(col) } \arguments{ \item{col}{List of colors (see Details).} } \details{ In order for \samp{triax.fill} to fill an existing plot that has been created by a call to \samp{triax.plot}, the user must supply a list of fill colors. The first element of the list must begin with at least one value that can be interpreted as a color. The second element must begin with at least three such values, and so on, adding two values for each element of the list. Each list element will be displayed as a row of colored triangles starting at the top of the plot. The number of elements in the list determines the number of rows that will be displayed. } \value{nil} \author{Jim Lemon} \seealso{\link{triax.plot},\link{color.scale}} \examples{ # the data will be something like response at different proportions fillval<-list(0,c(0,0.1,0),c(0,0.1,0.2,0.1,0), c(0,0.1,0.2,0.3,0.2,0.1,0),c(0,0.1,0.2,0.3,0.4,0.3,0.2,0.1,0), c(0,0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1,0), c(0,0,0.1,0.2,0.3,0.4,0.5,0.4,0.3,0.2,0.1,0,0), c(0,0,0,0.1,0.1,0.2,0.3,0.4,0.3,0.2,0.1,0.1,0,0,0)) # use some method of converting values to colors fillcol<-sapply(fillval,function(x) {x*10+1} ) oldpar<-triax.plot(main="Test of triax.fill function") triax.fill(fillcol) par(oldpar) } \keyword{misc} plotrix/man/triax.abline.Rd0000755000176000001440000000252411324077334015437 0ustar ripleyusers\name{triax.abline} \alias{triax.abline} \title{Lines for triangle plot} \description{ Display lines on a triangle plot. } \usage{ triax.abline(b=NULL,r=NULL,l=NULL,col=par("col"),lty=par("lty"), cc.axes=FALSE) } \arguments{ \item{b}{Lines relating to the bottom axis.} \item{r}{Lines relating to the right axis.} \item{l}{Lines relating to the left axis.} \item{col}{Color(s) of the lines.} \item{lty}{Type(s) of the lines.} \item{cc.axes}{Clockwise/counterclockwise axes and ticks.} } \details{ \samp{triax.abline} displays one or more lines on a triangle plot. Lines are oriented in the conventional way, horizontal for the left axis, slanting up to the right for the right axis and up to the left for the bottom axis. If \samp{cc.axes} is TRUE, the orientation is up-left for the left axis, horizontal for the right axis and up-right for the bottom axis. Remember to call \samp{triax.plot} with \samp{no.add=FALSE} and restore the graphics parameters as in the example or the lines will not be placed properly. } \value{nil} \author{Jim Lemon} \seealso{\link{triax.plot}} \examples{ triax.return<-triax.plot(data.frame(bottom=0.4,right=0.3,left=0.3), main="Triax ablines",no.add=FALSE) triax.abline(l=0.3,col="red") triax.abline(r=0.3,col="green") triax.abline(b=0.4,col="blue") par(triax.return$oldpar) } \keyword{misc} plotrix/man/thigmophobe.labels.Rd0000755000176000001440000000523211573377330016631 0ustar ripleyusers\name{thigmophobe.labels} \title{Place labels away from the nearest point} \usage{ thigmophobe.labels(x,y,labels=NULL,text.pos=NULL,...) } \alias{thigmophobe.labels} \arguments{ \item{x,y}{Numeric data vectors or a list with two components. Typically the x/y coordinates of plotted points.} \item{labels}{A vector of strings that will be placed adjacent to each point. Defaults to the indices of the coordinates.} \item{text.pos}{An optional vector of text positions (see \link{text}).} \item{...}{additional arguments are passed to \samp{text}}. } \description{ \samp{thigmophobe.labels} places labels adjacent to each point, offsetting each label in the direction returned by \samp{thigmophobe}. } \details{ Typically used to automatically place labels on a scatterplot or similar to avoid overlapping labels. \samp{thigmophobe.labels} will sometimes place a label off the plot or fail to separate labels in clusters of points. The user can manually adjust the errant labels by running \samp{thigmophobe} first and saving the returned vector. Then modify the position values to place the labels properly and pass the edited vector to \samp{thigmophobe.labels} as the \samp{text.pos} argument. This takes precedence over the positions calculated by \samp{thigmophobe}. \samp{thigmophobe} will fail with only two labels, as it can't figure out the nearest neighbors. If you really want to use this with two labels, just eyeball the plot and work out in which direction the labels will go. Then pass the directions to \samp{thigmophobe.labels} as the \samp{text.pos} argument. Both \samp{pointLabel} in the \pkg{maptools} package and \samp{spread.labs} in the \pkg{TeachingDemos} package use more sophisticated algorithms to place the labels and are worth a try if \samp{thigmophobe} just won't get it right. } \value{ A vector of directions away from the point nearest to each point. } \keyword{misc} \author{Jim Lemon (thanks to Stephen Milborrow for finding the single point bug and Erik Aronesty for finding the two point problem.)} \seealso{\link{thigmophobe}, \link{text}} \examples{ x<-rnorm(20) y<-rnorm(20) xlim<-range(x) xspace<-(xlim[2]-xlim[1])/20 xlim<-c(xlim[1]-xspace,xlim[2]+xspace) ylim<-range(y) yspace<-(ylim[2]-ylim[1])/20 ylim<-c(ylim[1]-yspace,ylim[2]+yspace) plotlabels<- c("one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen","nineteen","twenty") plot(x=x,y=y,xlim=xlim,ylim=ylim,main="Test thigmophobe.labels") # skip the almost invisible yellow label, make them bold thigmophobe.labels(x,y,plotlabels,col=c(2:6,8:12),font=2) } plotrix/man/thigmophobe.Rd0000755000176000001440000000207511573377131015371 0ustar ripleyusers\name{thigmophobe} \title{Find the direction away from the closest point} \description{Find the direction away from the closest point} \usage{ thigmophobe(x,y) } \alias{thigmophobe} \arguments{ \item{x,y}{Numeric data vectors. Typically the x/y coordinates of plotted points. If arrays are passed, they will be silently coerced to numeric vectors.} } \details{ \samp{thigmophobe} returns the direction (as 1|2|3|4 - see pos= in \samp{text}) away from the nearest point to each of the points described by \samp{x} and \samp{y}. } \note{ \samp{thigmophobe} is typically used to get the offset to automatically place labels on a scatterplot or similar using \samp{thigmophobe.labels} to avoid overlapping labels. The name means "one who fears being touched". } \value{ A vector of directions away from the point nearest to each point. } \keyword{misc} \author{Jim Lemon - thanks to Gustaf Rydevik for the "names" bug fix and to Steve Ellison for the suggestion about arrays.} \seealso{\link{thigmophobe.labels}} \examples{ x<-rnorm(10) y<-rnorm(10) thigmophobe(x,y) } plotrix/man/textbox.Rd0000755000176000001440000000555512005141612014547 0ustar ripleyusers\name{textbox} \alias{textbox} \title{Add text box} \description{ Add text to plot, justified, in a box } \usage{ textbox(x, y, textlist, justify=c('l','c','r'), cex=1, leading=0.5, box=TRUE, adj=c(0,0), font=NULL, vfont=NULL, col=NULL, border=NULL, fill=NA, density=NULL, angle=45, lty=par("lty"), lwd=par("lwd"), margin=0) } \arguments{ \item{x}{x position: a vector with min. and max. x-position} \item{y}{y position: location of the top of the box} \item{textlist}{a vector of text strings} \item{justify}{x alignment: 'l'=left, 'c'=center, 'r'=right.} \item{cex}{character expansion} \item{leading}{inter-line spacing} \item{box}{whether to draw a box around the text} \item{adj}{adjustment for x and y position, default is no adjustment, see Details} \item{font}{text font, see Details} \item{vfont}{text font, see Details} \item{col}{text color} \item{border}{box border color} \item{fill}{box fill color} \item{density}{box shading line density, see Details} \item{angle}{box shading line angle, see Details} \item{lty}{box border and shading line types, see Details} \item{lwd}{box border and shading line width, see Details} \item{margin}{amount to adjust box border in or out. See Details} } \details{ Draws text in the box by pasting the textlist vector together, splitting it into words, and then adding words to the current line until the line is wide enough before moving on to the next line. \samp{margin} may be a vector of 1, 2, or 4 values, corresponding to adjustment of all borders (1 value), top/bottom and left/right borders (2 values), or bottom/left/top/right borders (4 values). A positive value moves text inwards from specified (x,y) position with border remaining at (x,y), and a negative value moves the border outwards from (x,y) with the text remaining at (x,y). The \samp{density} and \samp{angle} arguments have the same behavior as in the \samp{rect} function. The \samp{adj, font} and {vfont} arguments have the same behavior as in the \samp{text} function. The \samp{lty} and \samp{lwd} arguments have the same behavior as in the \samp{lines} function. } \value{ y-position of bottom line of box, or y-position of next line if there is no box. } \author{Ben Bolker. Improvements by Ted Toal.} \examples{ plot.new() textbox(c(0,0.2), 1, c("many words","more words","why not?", "keep going",rep("and going",10))) textbox(c(0.3,0.5), 1, c("keep going",rep("and going",10)), cex=0.45, col="blue", border="red", fill="#00FFEE80", density=25, angle=60) textbox(c(0.6,0.8), 1, c("keep going",rep("and going",10)), justify='c', cex=0.6, leading=1, font=4, border="gold", lty=2, lwd=4, margin=0.025) textbox(c(0.6,0.8), 0.5, c("keep going",rep("and going",10)), justify='r', cex=0.7, col="purple", font=3, border="green", margin=-0.025) lines(c(0,1), c(1,1), col="red", lty=2) lines(c(0,1), c(0.5,0.5), col="red", lty=2) } \keyword{aplot} plotrix/man/taylor.diagram.Rd0000755000176000001440000000761211711721151015770 0ustar ripleyusers\name{taylor.diagram} \alias{taylor.diagram} \title{ Taylor diagram } \description{ Display a Taylor diagram} \usage{ taylor.diagram(ref,model,add=FALSE,col="red",pch=19,pos.cor=TRUE, xlab="",ylab="",main="Taylor Diagram",show.gamma=TRUE,ngamma=3, gamma.col=8,sd.arcs=0,ref.sd=FALSE,grad.corr.lines=c(0.2,0.4,0.6,0.8,0.9), pcex=1,cex.axis=1,normalize=FALSE,mar=c(5,4,6,6),...) } \arguments{ \item{ref}{numeric vector - the reference values.} \item{model}{numeric vector - the predicted model values.} \item{add}{whether to draw the diagram or just add a point.} \item{col}{the color for the points displayed.} \item{pch}{the type of point to display.} \item{pos.cor}{whether to display only positive (\samp{TRUE}) or all values of correlation (\samp{FALSE}).} \item{xlab,ylab}{plot axis labels.} \item{main}{title for the plot.} \item{show.gamma}{whether to display standard deviation arcs around the reference point (only for \samp{pos.cor=TRUE}).} \item{ngamma}{the number of gammas to display (default=3).} \item{gamma.col}{color to use for the gamma arcs (only with pos.cor=TRUE).} \item{sd.arcs}{whether to display arcs along the standard deviation axes (see Details).} \item{ref.sd}{whether to display the arc representing the reference standard deviation.} \item{grad.corr.lines}{the values for the radial lines for correlation values (see Details).} \item{pcex}{character expansion for the plotted points.} \item{cex.axis}{character expansion for the axis text.} \item{normalize}{whether to normalize the models so that the reference has a standard deviation of 1.} \item{mar}{margins - only applies to the \samp{pos.cor=TRUE} plot.} \item{...}{Additional arguments passed to \samp{plot}.} } \details{ The Taylor diagram is used to display the quality of model predictions against the reference values, typically direct observations. A diagram is built by plotting one model against the reference, then adding alternative model points. If \samp{normalize=TRUE} when plotting the first model, remember to set it to \samp{TRUE} when plotting additional models. Two displays are available. One displays the entire range of correlations from -1 to 1. Setting \samp{pos.cor} to \samp{FALSE} will produce this display. The -1 to 1 display includes a radial grid for the correlation values. When \samp{pos.cor} is set to \samp{TRUE}, only the range from 0 to 1 will be displayed. The \samp{gamma} lines and the arc at the reference standard deviation are optional in this display. Both the standard deviation arcs and the gamma lines are optional in the \samp{pos.cor=TRUE} version. Setting \samp{sd.arcs} or \samp{grad.corr.lines} to zero or FALSE will cause them not to be displayed. If more than one value is passed for \samp{sd.arcs}, the function will try to use the values passed, otherwise it will call \samp{pretty} to calculate the values. } \value{ The values of \samp{par} that preceded the function. This allows the user to add points to the diagram, then restore the original values. This is only necessary when using the 0 to 1 correlation range. } \references{ Taylor, K.E. (2001) Summarizing multiple aspects of model performance in a single diagram. Journal of Geophysical Research, 106: 7183-7192. } \author{Olivier Eterradossi with modifications by Jim Lemon} \examples{ # fake some reference data ref<-rnorm(30,sd=2) # add a little noise model1<-ref+rnorm(30)/2 # add more noise model2<-ref+rnorm(30) # display the diagram with the better model oldpar<-taylor.diagram(ref,model1) # now add the worse model taylor.diagram(ref,model2,add=TRUE,col="blue") # get approximate legend position lpos<-1.5*sd(ref) # add a legend legend(lpos,lpos,legend=c("Better","Worse"),pch=19,col=c("red","blue")) # now restore par values par(oldpar) # show the "all correlation" display taylor.diagram(ref,model1,pos.cor=FALSE) taylor.diagram(ref,model2,add=TRUE,col="blue") } \keyword{misc} plotrix/man/tab.title.Rd0000755000176000001440000000250411334502600014731 0ustar ripleyusers\name{tab.title} \alias{tab.title} \title{ Display the title of a plot as a colored tab } \description{ Display the title of a plot as a colored tab. } \usage{ tab.title(label,text.col=par("fg"),tab.col=par("bg"),border=par("fg"), lwd=par("lwd"),cex=1.5,pad.mult=1.6,radius=0) } \arguments{ \item{label}{The title for the plot.} \item{text.col}{The color for the title text.} \item{tab.col}{The color for the tab fill.} \item{border}{The color for the tab border.} \item{lwd}{The line width for the border.} \item{cex}{Character expansion for the title.} \item{pad.mult}{How much higher to make the tab relative to the label.} \item{radius}{What proportion of the tab corners to round off.} } \value{ nil } \details{ \samp{tab.title} displays the plot title in a colored tab. The tab can be rounded at the upper corners by specifying the proportion of the tab height to be rounded as a number between 0 and 1. If the tab is too high to fit on the figure region, a warning will be displayed and the tab will still be shown. } \author{Jim Lemon} \seealso{\link{polygon}} \examples{ testx<-matrix(cumsum(rnorm(30)^2)+1,nrow=10) stackpoly(testx,main="", xaxlab=c("One","Two","Three","Four","Five", "Six","Seven","Eight","Nine","Ten"),staxx=TRUE) tab.title("Three Squiggly Lines",tab.col="yellow",radius=0.5) } \keyword{misc} plotrix/man/symbolbox.Rd0000755000176000001440000000203411324077064015071 0ustar ripleyusers\name{symbolbox} \alias{symbolbox} \title{Draw a box filled with symbols} \description{ Draws a box on the current figure that is filled with symbols representing individual counts } \usage{ symbolbox(x1,y1,x2,y2,tot,relw=0.5,fg=par("fg"),bg=par("bg"),box=TRUE, debug = TRUE,...) } \arguments{ \item{x1}{left side of box} \item{y1}{bottom side of box} \item{x2}{right side of box} \item{y2}{top side of box} \item{tot}{total number of symbols to put in the box} \item{relw}{relative width (relative to height) of symbols} \item{fg}{foreground color} \item{bg}{background color} \item{box}{(logical) draw box border?} \item{debug}{debug output?} \item{\dots}{additional arguments to polygon() for drawing box} } \details{ tries to automatically figure out appropriate scaling to fit symbols into the box } \value{ none; draws on the current figure } \author{Ben Bolker} \seealso{\link{multsymbolbox}} \examples{ plot(1:10,1:10,type="n") symbolbox(2,5,3,7,tot=20) symbolbox(6,2,10,6,tot=50,fg="blue",bg="magenta") } \keyword{aplot} plotrix/man/symbolbarplot.Rd0000755000176000001440000000313011146476452015750 0ustar ripleyusers\name{symbolbarplot} \alias{symbolbarplot} \title{barplot filled with symbols} \description{ Produces a barplot where each piece of the barplot is filled with the number of symbols equal to the size of the bar } \usage{ symbolbarplot(height,width=1,space=NULL,names.arg=NULL, legend.text=NULL,beside=FALSE,horiz=FALSE,col=heat.colors(NR), border=par("fg"),main=NULL,sub=NULL,xlab=NULL,ylab=NULL,xlim=NULL, ylim=NULL,axes=TRUE,axisnames=TRUE,inside=TRUE,plot=TRUE,rel.width=0.8, symbol="circles",symbbox=TRUE,debug=FALSE,...) } \arguments{ \item{height}{numeric vector or matrix of barplot heights} \item{width}{width of bars} \item{space}{space between bars} \item{names.arg}{vector of names} \item{legend.text}{vector of legend text} \item{beside}{(logical) plot bars beside each other?} \item{horiz}{(logical) horizontal barplot?} \item{col}{vector of colors} \item{border}{plot border?} \item{main}{main title} \item{sub}{subtitle} \item{xlab}{x axis label} \item{ylab}{y axis label} \item{xlim}{x limits} \item{ylim}{y limits} \item{axes}{draw axes?} \item{axisnames}{label horizontal axis?} \item{inside}{draw lines dividing adjacent bars?} \item{plot}{produce plot?} \item{rel.width}{relative width of symbols} \item{symbol}{which symbol to use} \item{symbbox}{draw boxes for symbol boxes?} \item{debug}{debug output?} \item{\dots}{further arguments to multsymbolbox} } \value{ Nil } \note{This is a mostly a hack of barplot()} \author{Ben Bolker} \examples{ set.seed(1001) bvals <- matrix(rpois(12,20),nrow=3) b <- symbolbarplot(bvals) } \keyword{hplot} plotrix/man/sumbrk.Rd0000644000176000001440000000123311557247143014360 0ustar ripleyusers\name{sumbrk} \alias{sumbrk} \title{Count specified values in a vector} \description{ Counts the number of values in a vector that are equal to a specified value. } \usage{ sumbrk(x,trueval=TRUE,na.rm=TRUE) } \arguments{ \item{x}{a character, factor or numeric vector.} \item{trueval}{the value to be matched in \samp{x}.} \item{na.rm}{whether to remove NA values.} } \details{ \samp{sumbrk} counts the values matching a specified value. It is mainly to allow these sums to be calculated in the \samp{brkdnNest} function. } \value{nil} \author{Jim Lemon} \seealso{\link{brkdnNest}} \examples{ sumbrk(sample(LETTERS,100,TRUE),trueval="M") } \keyword{misc} plotrix/man/sumDendrite.Rd0000755000176000001440000000153211334502554015336 0ustar ripleyusers\name{sumDendrite} \alias{sumDendrite} \title{Sum the counts in the top level of a dendrite object} \description{Find the sum of the counts that are the first elements of each list in the top level of a dendrite object.} \usage{ sumDendrite(x) } \arguments{ \item{x}{A list with a numeric value as the first element in each of its toplevel elements.} } \details{ A \samp{dendrite} object is a possibly nested list of lists that contain the counts and pointers to sublists in each list. Such an object describes the attributes of objects that can take on mutually exclusive attributes (that is, belong to disjunct sets). \samp{sumDendrite} is a convenience function to get the total number of objects that are so classified. } \value{The sum of the counts in the top level of lists.} \keyword{misc} \author{Jim Lemon} \seealso{\link{plot.dendrite}} plotrix/man/std.error.Rd0000755000176000001440000000074711324077002014776 0ustar ripleyusers\name{std.error} \alias{std.error} \title{Calculate standard error of the mean} \description{ Calculates the standard error of the mean. } \usage{ std.error(x,na.rm) } \arguments{ \item{x}{A vector of numerical observations.} \item{na.rm}{Dummy argument to match other functions.} } \details{ \samp{std.error} will accept a numeric vector. } \value{ The conventional standard error of the mean = sd(x)/sqrt(sum(!is.na(x))) } \author{Jim Lemon} \seealso{\link{sd}} \keyword{misc} plotrix/man/staxlab.Rd0000755000176000001440000000402711712450562014514 0ustar ripleyusers\name{staxlab} \alias{staxlab} \title{ Place staggered or angled labels on an axis } \description{ Places labels on an axis in a regular staggered order or at an angle } \usage{ staxlab(side=1,at,labels,nlines=2,top.line=0.5,line.spacing=0.8, srt=NA,ticklen=0.03,adj=1,...) } \arguments{ \item{side}{axis on which to place the labels, as in \samp{axis}} \item{at}{where to place the labels in user units, as in \samp{axis}} \item{labels}{text strings} \item{nlines}{How many lines to use to stagger the labels.} \item{top.line}{Distance from the axis to place the first line of text.} \item{line.spacing}{Spacing between lines of text labels.} \item{srt}{Text rotation.} \item{ticklen}{Proportion of plot height in user units to place text below the plot.} \item{adj}{horizontal adjustment of the labels.} \item{...}{Additional arguments to be passed to \samp{mtext} or \samp{text}.} } \note{ This function is mainly useful when either long axis labels or a large number of labels are to be placed without overlapping. It staggers the labels along the axis specified. The user may wish to increase the space beneath the plot using \samp{mar} before calling \samp{staxlab}. It is probably only useful on the bottom or left side of the plot. If \samp{srt} is not NA, the labels will be rotated \samp{srt} degrees and placed below the plot. This method will only place labels at the bottom. Note that this option only works on the lower and left axes. } \value{nil} \author{Jim Lemon (thanks to Tim Elwell-Sutton for the log axis fix)} \seealso{\link{mtext}} \examples{ x<-rnorm(12) plot(x,axes=FALSE) box() months<-c("January","February","March","April","May","June", "July","August","September","October","November","December") staxlab(1,1:12,months) plot(x,axes=FALSE) box() months<-c("January","February","March","April","May","June", "July","August","September","October","November","December") staxlab(1,1:12,months,srt=45) ylabels<-round(seq(min(x),max(x),length.out=10),3) staxlab(2,ylabels,ylabels,srt=45) } \keyword{misc} plotrix/man/staircase.plot.Rd0000755000176000001440000000651212112003126015773 0ustar ripleyusers\name{staircase.plot} \alias{staircase.plot} \title{Display a staircase plot} \description{ Displays a plot showing a sequence of changing totals and increments as successive linked bars. } \usage{ staircase.plot(heights,totals=NA,labels=NULL,halfwidth=0.3,main="", mar=NA,total.col="blue",inc.col=NA,bg.col=NA,direction="e",las=1, display.height=TRUE,stagger=FALSE,cex=par("cex"),prefix="",suffix="",...) } \arguments{ \item{heights}{vector of numeric values or a matrix or data frame with at least two columns. The first column must be numeric and the second may be numeric or logical.} \item{totals}{A vector of logicals or zero/non-zero values indicating whether the corresponding height is a total (TRUE) or an increment (FALSE).} \item{labels}{An optional vector of labels for the bars.} \item{halfwidth}{Half of the width of a bar as a proportion. See Details.} \item{main}{A title for the plot.} \item{mar}{Margins for the plot. Defaults to 10 on the baseline axis, 3 on the top and 1 on the other two sides.} \item{total.col}{Color(s) for the bars representing successive totals.} \item{inc.col}{Color(s) for the bars representing increments.} \item{bg.col}{The background color for the plot.} \item{direction}{Direction in which the bars should be presented. See Details.} \item{las}{Orientation for the bar labels. See \samp{par}.} \item{display.height}{Whether to display the totals and increments at the upper ends of the bars. Defaults to TRUE.} \item{stagger}{Whether to stagger the labels to avoid overlap.} \item{cex}{The usual character expansion value.} \item{prefix}{A prefix to the numbers displayed next to the bars (e.g. $).} \item{suffix}{A suffix as for prefix (e.g. \%).} \item{...}{arguments passed to \samp{plot}.} } \value{nil} \details{ Displays a plot representing successive changes in counts or values. For example, if a research study attempts to contact a certain number of people and some cannot be contacted, some decline to participate, some are ineligible, the final sample will be smaller than the initial contact list. The first value will be the total of attempts, there will be a number of decrements, and the last value will be the actual sample. There may be intermediate totals specified. This produces a visual display of the sampling procedure. See the example. The bars are placed at integer values on the axis representing the succession of counts or values. The width of the bars is determined by the argument \samp{halfwidth}. This defaults to 0.3, meaning that the bar extends 0.3 to each side, so that the proportion of bar to space is 0.6 to 0.4. The succession of bars is determined by the \samp{direction} argument. The default is "e" (east), meaning that the first bar is at the left of the plot and subsequent bars are placed to the right. The other three possibilities follow the conventional compass layout. The \samp{prefix} and \samp{suffix} arguments allow the user to specify units for the numbers displayed next to the bars. If a single value is passed, all numbers will get the same prefix or suffix. Different prefixes or suffixes for each number can be passed as vectors. The \samp{getFigCtr} function is called to center the plot title in the figure region as the plot area is typically off center. } \author{Jim Lemon} \seealso{\link{plot}, \link{getFigCtr}} \keyword{misc} plotrix/man/stackpoly.Rd0000755000176000001440000000624311646766121015100 0ustar ripleyusers\name{stackpoly} \alias{stackpoly} \title{ Display the columns of a matrix or data frame as stacked polygons } \description{ Plot one or more columns of numeric values as the top edges of polygons instead of lines. } \usage{ stackpoly(x,y=NULL,main="",xlab="",ylab="",xat=NA,xaxlab=NA, xlim=NA,ylim=NA,lty=1,lwd=1,border=NA,col=NULL,staxx=FALSE,stack=FALSE, axis2=TRUE,axis4=TRUE,padj=0,...) } \arguments{ \item{x}{A numeric data frame or matrix with the \samp{x} values. If \samp{y} is NULL, these will become the \samp{y} values and the \samp{x} positions will be the integers from 1 to dim(x)[1].} \item{y}{The \samp{y} values.} \item{main}{The title for the plot.} \item{xlab,ylab}{x and y axis labels for the plot.} \item{xat}{Where to put the optional xaxlabs.} \item{xaxlab}{Optional labels for the x positions.} \item{xlim}{Optional x limits.} \item{ylim}{Optional y limits.} \item{lty}{Line type for the polygon borders.} \item{lwd}{Line width for the polygon borders.} \item{border}{Color for the polygon borders.} \item{col}{Color to fill the polygons. If NULL, \samp{rainbow} will be called to generate the colors. If NA, the polygons will not be filled.} \item{staxx}{Whether to call \samp{staxlab} to stagger the x axis labels.} \item{stack}{Whether to stack the successive values on top of each other.} \item{axis2}{Whether to display the left ordinate on the plot.} \item{axis4}{Whether to display the right ordinate on the plot.} \item{padj}{Vertical justfication of the x axis labels, defaulting to "top". Can be a vector with an element for each label.} \item{...}{Additional arguments passed to \samp{plot}.} } \value{ nil } \details{ \samp{stackpoly} is similar to a line plot with the area under the lines filled with color(s). Ideally, each successive set of y values is greater than the values in the previous set so that the polygons form a rising series of crests. If \samp{stack} is TRUE, this is not a problem unless some values of \samp{x} are negative. If \samp{x} or \samp{y} is a vector, not a matrix or list, the values will be displayed as a "waterfall plot". The options for \samp{axis2} and \samp{axis4} can be used to produce panel plots. See the last example. } \author{Jim Lemon and Thomas Petzoldt (waterfall plot option)} \seealso{\link{polygon}} \examples{ testx<-matrix(abs(rnorm(100)),nrow=10) stackpoly(matrix(cumsum(testx),nrow=10),main="Test Stackpoly I", xaxlab=c("One","Two","Three","Four","Five", "Six","Seven","Eight","Nine","Ten"),border="black",staxx=TRUE) stackpoly(testx,main="Test Stackpoly II", xaxlab=c("One","Two","Three","Four","Five", "Six","Seven","Eight","Nine","Ten"),border="black", staxx=TRUE,stack=TRUE) layout(matrix(1:2,nrow=1)) oldmar<-par(mar=c(5,4,4,0)) stackpoly(rev(sort(testx-mean(testx))), main="Waterfall Plot (x-mean)",xat=seq(10,90,by=10), xlab="Index",ylab="Value",lwd=3,col="green",border="black", axis4=FALSE) ylim<-par("usr")[3:4] par(mar=c(5,0,4,4)) stackpoly(rev(sort((testx-mean(testx))/sd(as.vector(testx)))), ylim=ylim,main="Waterfall Plot ((x-mean)/sd)",xat=seq(10,90,by=10), xlab="Index",lwd=3,col="lightblue",border="black",axis2=FALSE) par(oldmar) } \keyword{misc} plotrix/man/spreadout.Rd0000755000176000001440000000245211334502470015060 0ustar ripleyusers\name{spreadout} \alias{spreadout} \title{Spread out a vector of numbers to a minimum interval} \description{ Spread out a vector of numbers so that there is a minimum interval between any two numbers when in ascending or descending order. } \usage{ spreadout(x,mindist) } \arguments{ \item{x}{A numeric vector which may contain NAs.} \item{mindist}{The minimum interval between any two values when in ascending or descending order.} } \details{ \samp{spreadout} starts at or near the middle of the vector and increases the intervals between the ordered values. NAs are preserved. \samp{spreadout} first tries to spread groups of values with intervals less than \samp{mindist} out neatly away from the mean of the group. If this doesn't entirely succeed, a second pass that forces values away from the middle is performed. \samp{spreadout} is currently used to avoid overplotting of axis tick labels where they may be close together. } \value{ On success, the spread out values. If there are less than two valid values, the original vector is returned. } \author{Jim Lemon} \examples{ spreadout(c(1,3,3,3,3,5),0.2) spreadout(c(1,2.5,2.5,3.5,3.5,5),0.2) spreadout(c(5,2.5,2.5,NA,3.5,1,3.5,NA),0.2) # this will almost always invoke the brute force second pass spreadout(rnorm(10),0.5) } \keyword{misc} plotrix/man/spread.labels.Rd0000755000176000001440000000540011520247134015565 0ustar ripleyusers\name{spread.labels} \alias{spread.labels} \title{ Spread labels for irregularly spaced values } \description{ Places labels for irregularly spaced values in a regular staggered order } \usage{ spread.labels(x,y,labels=NULL,ony=NA,offsets=NA,between=FALSE, linecol=par("fg"),srt=0,...) } \arguments{ \item{x,y}{x and y data values} \item{labels}{text strings} \item{ony}{Whether to force the labels to be spread horizontally (FALSE) or vertically (TRUE). Defaults to whichever way the points are most spread out.} \item{offsets}{How far away from the data points to place the labels. Defaults to one quarter of the plot span for all, staggered on each side.} \item{between}{Whether to place the labels between two sets of points.} \item{linecol}{Optional colors for the lines drawn to the points.} \item{srt}{Rotation of the labels in degrees.} \item{...}{additional arguments passed to \samp{text}.} } \details{ This function is mainly useful when labeling irregularly spaced data points that are "spread out" along one dimension. It places the labels regularly spaced and staggered on the long dimension of the data, drawing lines from each label to the point it describes. If \samp{between} is TRUE, the function expects two points for each label and will attempt to place the labels between two vertical lines of points. Lines will be drawn from the ends of each label to the two corresponding points. If spreading labels horizontally, the user may wish to rotate the labels by 90 degrees (\samp{srt=90}). If long labels run off the edge of the plot, increase the \samp{xlim} for extra room. } \value{nil} \author{Jim Lemon} \references{ Cooke, L.J. & Wardle, J. (2005) Age and gender differences in children's food preferences. British Journal of Nutrition, 93: 741-746. } \seealso{\samp{text}, \samp{spread.lab (TeachingDemos)}} \examples{ # spread labels out in the x dimension using defaults x<-sort(rnorm(10)) y<-rnorm(10)/10 plot(x,y,ylim=c(-1,1),type="p") nums<-c("one","two","three","four","five","six","seven","eight","nine","ten") spread.labels(x,y,nums) # food preferences of children by sex (Cooke & Wardle, 2005) fpkids<-data.frame(Food=c("Fatty/sugary","Fruit","Starchy","Meat", "Proc.meat","Eggs","Fish","Dairy","Vegetables"), Female=c(4.21,4.22,3.98,3.57,3.55,3.46,3.34,3.26,3.13), Male=c(4.35,4.13,4.02,3.9,3.81,3.64,3.45,3.27,2.96)) plot(rep(1,9),fpkids$Female,xlim=c(0.8,2.2), ylim=range(c(fpkids$Female,fpkids$Male)),xlab="Sex",xaxt="n", ylab="Preference rating",main="Children's food preferences by sex", col="red") axis(1,at=1:2,labels=c("Female","Male")) points(rep(2,9),fpkids$Male,col="blue",pch=2) spread.labels(rep(1:2,each=9),c(fpkids$Female,fpkids$Male), fpkids$Food,between=TRUE,linecol=c("red","blue")) } \keyword{misc} plotrix/man/soils.Rd0000755000176000001440000000062611056465626014220 0ustar ripleyusers\name{soils} \alias{soils} \title{Soil texture data from 125 soils} \description{ A set of 125 soil texture measurements from soils from various parts of the world. } \usage{ data(soils) } \source{ T.H. Skaggs, L.M. Arya, P.J. Shouse and B.P. Mohanty (2001) Estimating Particle-Size Distribution from Limited Soil Texture Data. Soil Science Society of America Journal 65:1038-1044. } \keyword{misc} plotrix/man/soil.texture.uk.Rd0000755000176000001440000001003111324076510016125 0ustar ripleyusers\name{soil.texture.uk} \alias{soil.texture.uk} \title{Soil texture triangle plot using UK conventions} \description{ Display a UK style soil texture triangle with optional grid, labels and soil texture points. } \usage{ soil.texture.uk(soiltexture = NULL, main = "",at = seq(0.1, 0.9, by = 0.1), axis.labels = c("percent sand", "percent silt", "percent clay"), tick.labels = list(l = seq(10, 90, by = 10), r = seq(10, 90, by = 10), b = seq(10, 90, by = 10)), show.names = TRUE, show.lines = TRUE, col.names = "gray", bg.names = par("bg"), show.grid = FALSE, col.axis = "black", col.lines = "gray", col.grid = "gray", lty.grid = 3, show.legend = FALSE, label.points = FALSE, point.labels = NULL, col.symbols = "black", pch = par("pch"), h1 = NA, h3 = NA, t1 = NA, t3 = NA, lwduk = 2, xpos = NA, ypos = NA, snames = NA, cexuk = 1.1, ...) } \arguments{ \item{soiltexture}{Matrix of soil textures where each row is a soil sample and three columns containing the percentages of the components sand, silt and clay in the range 0 to 100.} \item{main}{The title of the soil texture plot. Defaults to nothing.} \item{at}{Positions on the three axes where ticks will be drawn.} \item{axis.labels}{Labels for the axes.} \item{tick.labels}{The tick labels for the three axes.} \item{show.names}{Logical - whether to show the names of different soil types within the soil triangle.} \item{show.lines}{Logical - whether to show the boundaries of the different soil types within the soil triangle.} \item{col.names}{Color of the soil names. Defaults to gray.} \item{bg.names}{Color to use when drawing a blank patch for the names of soil types.} \item{show.grid}{Logical - whether to show grid lines at each 10% level of each soil component.} \item{col.axis}{Color of the triangular axes, ticks and labels.} \item{col.lines}{Color of the boundary lines. Defaults to gray.} \item{col.grid}{Color of the grid lines. Defaults to gray.} \item{lty.grid}{Type of line for the grid. Defaults to dashed.} \item{show.legend}{Logical - whether to display a legend.} \item{label.points}{Logical - whether to call \link{thigmophobe.labels} to label the points.} \item{point.labels}{Optional labels for the points or legend.} \item{col.symbols}{Color of the symbols representing each value.} \item{pch}{Symbols to use in plotting values.} \item{h1,h3,t1,t3}{Points used in drawing boundaries for soil types.} \item{lwduk}{Line width for the boundaries} \item{xpos,ypos}{Positions for the soil type labels.} \item{snames}{Soil type labels.} \item{cexuk}{Character expansion for the soil type labels.} \item{...}{Additional arguments passed to \link{triax.points} and then \samp{points}.} } \details{ \samp{soil.texture.uk} displays a triangular plot area on which soil textures defined as proportions of sand, silt and clay can be plotted. It is similar to the \samp{soil.texture} function but uses the UK display conventions. } \value{If \samp{soiltexture} was included, a list of the \samp{x,y} positions of the soil types plotted. If not, nil. } \author{Julian Stander} \seealso{\link{triax.plot}} \examples{ soils.sw.percent<-data.frame( Sand=c(67,67,66,67,36,25,24,59,27,9,8,8,20, 45,50,56,34,29,39,41,94,98,97,93,96,99), Silt=c(17,16,9,8,39,48,54,27,46,70,68,68,66, 34,30,24,48,53,46,48,2,2,2,4,1,1), Clay=c(16,17,25,25,25,27,22,14,27,21,24,24, 14,21,20,20,18,18,15,11,4,0,1,3,3,0)) soils.sw.cols <- c(1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6) soils.sw.names <- c("Ardington","Astrop","Atrim", "Banbury","Beacon","Beckfoot") soil.texture.uk(soils.sw.percent, main = "Ternary Diagram for Some Soils from South West England", col.lines = "black", col.names = "black", show.grid = TRUE, col.grid = "blue", lty.grid = 2, pch = 16, cex = 1.0, col.symbols = soils.sw.cols, h1 = NA, h3 = NA, t1 = NA, t3 = NA , lwduk = 2, xpos = NA, ypos = NA, snames = NA, cexuk = 1.1) legend("topleft", legend = soils.sw.names, col = 1:max(soils.sw.cols), pch = 16, cex = 1.1, title = "Location", bty = "n") } \keyword{misc} plotrix/man/soil.texture.Rd0000755000176000001440000000726511324076454015535 0ustar ripleyusers\name{soil.texture} \alias{soil.texture} \title{Soil texture triangle plot} \description{ Display a USDA soil texture triangle with optional grid, labels and soil texture points. } \usage{ soil.texture(soiltexture=NULL, main="", at=seq(0.1, 0.9, by=0.1), axis.labels=c("percent sand", "percent silt", "percent clay"), tick.labels=list(l=seq(10, 90, by=10), r=seq(10, 90, by=10), b=seq(10, 90, by=10)), show.names=TRUE, show.lines=TRUE, col.names="gray", bg.names=par("bg"), show.grid=FALSE, col.axis="black", col.lines="gray", col.grid="gray", lty.grid=3, show.legend=FALSE, label.points=FALSE, point.labels=NULL, col.symbols="black", pch=par("pch"), \dots) } \arguments{ \item{soiltexture}{Matrix of soil textures where each row is a soil sample and three columns contain the proportions of the components sand, silt and clay in the range 0 to 1 or percentages in the range 0 to 100.} \item{main}{The title of the soil texture plot. Defaults to nothing.} \item{at}{Positions on the three axes where ticks will be drawn.} \item{axis.labels}{Labels for the axes.} \item{tick.labels}{The tick labels for the three axes.} \item{show.names}{Logical - whether to show the names of different soil types within the soil triangle.} \item{show.lines}{Logical - whether to show the boundaries of the different soil types within the soil triangle.} \item{col.names}{Color of the soil names. Defaults to gray.} \item{bg.names}{Color to use when drawing a blank patch for the names of soil types.} \item{show.grid}{Logical - whether to show grid lines at each 10% level of each soil component.} \item{col.axis}{Color of the triangular axes, ticks and labels.} \item{col.lines}{Color of the boundary lines. Defaults to gray.} \item{col.grid}{Color of the grid lines. Defaults to gray.} \item{lty.grid}{Type of line for the grid. Defaults to dashed.} \item{show.legend}{Logical - whether to display a legend.} \item{label.points}{Logical - whether to call \link{thigmophobe.labels} to label the points.} \item{point.labels}{Optional labels for the points or legend.} \item{col.symbols}{Color of the symbols representing each value.} \item{pch}{Symbols to use in plotting values.} \item{\dots}{Additional arguments passed to \link{triax.points} and then \samp{points}.} } \details{ \samp{soil.texture} displays a triangular plot area on which soil textures defined as proportions of sand, silt and clay can be plotted. Optional grid, vertex labels, soil type divisions and names may also be displayed. If a matrix of soil textures is present, these will be plotted. } \value{If \samp{soiltexture} was included, a list of the \samp{x,y} positions of the soil types plotted. If not, nil. } \note{This is now a special case of \samp{triax.plot}.} \author{Sander Oom, Jim Lemon, and Michael Toews} \references{ U.S. Department of Agriculture, Natural Resources Conservation Service, 2007. \emph{National Soil Survey Handbook}, title 430-VI.// \url{http://soils.usda.gov/technical/handbook/} U.S. Department of Agriculture, Natural Resources Conservation Service, 2007. \emph{Soil Texture Calculator}// \url{http://soils.usda.gov/technical/aids/investigations/texture/} } \seealso{\link{get.soil.texture}, \link{triax.plot}} \examples{ data(soils) soil.texture(main="NO DATA") soil.texture(soils, main="DEFAULT", pch=2) soil.texture(soils, main="LINES AND NAMES", show.lines=TRUE, show.names=TRUE, pch=3) soiltex.return<-soil.texture(soils[1:6,], main="GRID AND LEGEND", show.grid=TRUE, pch=4, col.symbols=1:6, show.legend=TRUE) par(soiltex.return$oldpar) } \keyword{misc} plotrix/man/smoothColors.Rd0000755000176000001440000000231511334502414015541 0ustar ripleyusers\name{smoothColors} \alias{smoothColors} \title{Build a vector of color values} \usage{ smoothColors(...,alpha=NA) } \arguments{ \item{...}{an arbitrary sequence of color names and integers beginning and ending with a color name.} \item{alpha}{optional \samp{alpha} (transparency) value.} } \description{ \samp{smoothColors} calculates a sequence of colors. If two color names in the arguments are separated by a number, that number of interpolated colors will be inserted between the two color endpoints. Any number of color names and integers may be passed, but the last argument must be a color name. If more than one integer appears between two color names, only the first will be used in the interpolation and the others will be ignored. } \value{A vector of hexadecimal color values as used by \samp{col}.} \note{ For more R functions that transform numeric values into colors or produce colors that can be used to represent values, see the \pkg{colourschemes} package. } \author{Barry Rowlingson} \seealso{\link{color.gradient},\link{rgb}} \examples{ plot(1:10,main="Test opaque colors",type="n",axes=FALSE) box() rect(1:7,1:7,3:9,3:9,col=smoothColors("red",2,"green",2,"blue")) } \keyword{misc} plotrix/man/sliceArray.Rd0000644000176000001440000000143511556520354015154 0ustar ripleyusers\name{sliceArray} \alias{sliceArray} \title{Slice an array} \description{ Slices one dimension from an array by taking one element from the first dimension. } \usage{ sliceArray(x,slice) } \arguments{ \item{x}{An array} \item{slice}{The index of the slice to take from the first dimension of the array.} } \details{ \samp{sliceArray} builds an extractor string containing the value of \samp{slice} as the first element and as many commas as needed to match the dimensions of the array. It then applies the extractor function to \samp{x} and returns the result. Note how the array "slice" swaps dimensions in the example. } \value{ The desired slice of the array. } \author{Jim Lemon} \seealso{\link{array}} \examples{ a1<-array(1:27,dim=c(3,3,3)) a1 sliceArray(a1,2) } \keyword{misc} plotrix/man/sizetree.Rd0000755000176000001440000001302711732043353014706 0ustar ripleyusers\name{sizetree} \alias{sizetree} \title{Display a hierarchical breakdown of disjunct categories} \description{Display a data frame in which the values in each successive column represent subcategories of the previous column as stacked rectangles.} \usage{ sizetree(x,left=0,top,right=1,lastcenter=NA,showval=TRUE,showcount=TRUE, firstcall=TRUE,col=NULL,border=NA,toplab=NULL,base.cex=1,...) } \arguments{ \item{x}{A data frame in which each successive column represents subcategories of the previous column.} \item{left}{The left edge of the current stack of rectangles in user units.} \item{top}{The top of the current stack of rectangles in user units.} \item{right}{The right edge of the current stack of rectangles in user units.} \item{lastcenter}{The center of the previous rectangle from which the next breakdown of categories arises. There is almost no reason to change it.} \item{showval}{Whether to display the values representing the categories.} \item{showcount}{Whether to display the count for the categories.} \item{firstcall}{A flag for the function - do not alter this.} \item{col}{Optional fill colors for the rectangles. See Details} \item{border}{Color for border around the rectangles. See details} \item{toplab}{Optional labels to display a the top of each stack.} \item{base.cex}{The base character expansion for the labels.} \item{...}{additional arguments passed to \samp{plot}.} } \value{ nil } \details{ \samp{sizetree} displays disjunct hierarchical categories as stacked rectangles. It accepts a data frame in which the values in the first column represent categories, the values in the second column represent subcategories of the first column, and so on. The first column will be displayed as a stack of rectangles, the height of each proportional to the count for each category. Each substack of rectangles in the second stack will represent the breakdown of counts for its superordinate category and so on through the columns. Empty categories are ignored and NAs will produce gaps, which will propagate across subsequent stacks. The user can simply pass the data frame, which should only contain columns that are hierarchical categories (example 1). The colors will probably not be ideal. The user can pass the same colors for the all levels (example 2). If this is done, \samp{sizetree} will try to match colors to categories when the number of categories is diminishing (e.g. some levels are missing in the sub-categories) and the columns of \samp{x} are factors with the same levels in the same order. This will work if the category labels are the same in each level, but remember to add the names to the colors before passing them to the function. This will not work if there are more categories in the lower levels. If \samp{col} is a list, this is not done, and the user will have to work out the correct colors for each level. This is particularly important when the category labels and the number of categories is different in different levels (example 3). In some sizetrees, the subcategory counts are very low compared to the overall number of data objects. This results in rectangles that are very thin vertically. One way to get better legibility of the labels is to use dark colors for the rectangles, so that the labels are white, and no borders (set \samp{border} to NA). The user can also select only part of the data frame \samp{x} to expand sections of the sizetree as in the last example. The labels are sized to fit the vertical extent of the bars. However, it is possible that the labels may extend horizontally beyond the bar(s). The \samp{base.cex} argument can be used to shrink the labels if this happens. Remember that \samp{base.cex} will shrink all the labels, not just the ones that are too wide. The \samp{firstcall} argument is necessary for the function to initialize the plot, as each breakdown involves a recursive call. If it is changed, the best that can be expected is an uninformative plot. } \author{Jim Lemon} \seealso{\link{plot}} \examples{ cat1<-factor(sample(c("None","Low","Medium","High","Extreme"),40,TRUE), levels=c("None","Low","Medium","High","Extreme")) cat2<-factor(sample(c("None","Low","Medium","High"),40,TRUE), levels=c("None","Low","Medium","High")) cat3<-factor(sample(c("None","Low","High"),40,TRUE), levels=c("None","Low","High")) hcats<-data.frame(cat1,cat2,cat3) # throw in a few NAs hcats$cat1[10]<-NA hcats$cat2[c(15,20)]<-NA hcats$cat3[c(11,14,25)]<-NA # first let sizetree work out the colors sizetree(hcats,main="Sizetree with automatic colors") # now see what happens with a list of the same colors for each level bhcol<-c("#ff8080","#dddd80","#80ff80","#0000ff","#80dddd") sizetree(hcats,col=list(bhcol,bhcol,bhcol), main="Sizetree with the same colors each level") # finally, specify different colors for categories with different labels sexhaireye<-data.frame(sex=factor(sample(c("Male","Female"),50,TRUE)), hair=factor(sample(c("Blond","Red","Brown","Black"),50,TRUE)), eye=factor(sample(c("Gold","Green","Blue"),50,TRUE))) shecol<-list(c("pink","lightblue"),c("#000000","#dddd00","#886600","#ee8800"), c("blue","gold","green")) sizetree(sexhaireye,main="Sex, hair and eye color", col=shecol,toplab=c("Sex","Hair color","Eye color")) # now expand the female part of the sizetree sizetree(sexhaireye[sexhaireye[,1]=="Female",], main="Sex, hair and eye color (Females only)", col=shecol,toplab=c("Sex","Hair color","Eye color")) } \keyword{misc} plotrix/man/sizeplot.Rd0000755000176000001440000000251211324076262014724 0ustar ripleyusers\name{sizeplot} \alias{sizeplot} \title{Plot with repeated symbols by size} \description{ Plots a set of (x,y) data with repeated points denoted by larger symbol sizes } \usage{ sizeplot(x, y, scale=1, pow=0.5, powscale=TRUE, size=c(1,4), add=FALSE, ...) } \arguments{ \item{x}{x coordinates of data} \item{y}{y coordinates of data} \item{scale}{scaling factor for size of symbols} \item{pow}{power exponent for size of symbols} \item{powscale}{(logical) use power scaling for symbol size?} \item{size}{(numeric vector) min and max size for scaling, if powscale=FALSE} \item{add}{(logical) add to an existing plot?} \item{\dots}{other arguments to \samp{plot()} or \samp{points()}} } \details{ Most useful for plotting (e.g.) discrete data, where repeats are likely. If all points are repeated equally, gives a warning. The size of a point is given by \eqn{scale*n^pow}, where n is the number of repeats, if powscale is TRUE, or it is scaled between size[1] and size[2], if powscale is FALSE. } \value{ A plot is produced on the current device, or points are added to the current plot if \samp{add=TRUE}. } \author{Ben Bolker} \seealso{\link{symbols}} \examples{ x <- c(0.1,0.1,0.1,0.1,0.1,0.2,0.2,0.2,0.2,0.3,0.3) y <- c( 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5 ) plot(x,y) sizeplot(x,y) sizeplot(x,y,pch=2) } \keyword{hplot} plotrix/man/size_n_color.Rd0000644000176000001440000000760011736033067015543 0ustar ripleyusers\name{size_n_color} \alias{size_n_color} \title{Display circles with specified size and color} \description{Display a plot of circles at specified locations, each with a specified size and color.} \usage{ size_n_color(x=NULL,y,size,sizefun="sqrt",col,main="", xlim=NA,xlab="",xat=NULL,xaxlab=NULL,xcex=1,xlas=0,xgrid=FALSE, ylim=NA,ylab="",yat=NULL,yaxlab=NULL,ycex=1,ylas=1,ygrid=TRUE, mar=c(5,4,4,2),boxit=TRUE,add=FALSE,...) } \arguments{ \item{x,y}{Vectors or matrices of x and y positions for the symbols.} \item{size}{Sizes for the symbols expressed as numbers.} \item{sizefun}{The function to use for transforming the values to radii of circles. Square root gives areas proportional to the values.} \item{col}{Colors for the symbols (see Details).} \item{main}{Title for the plot.} \item{xlim,ylim}{Explicit x and y limits for the plot}. \item{xlab,ylab}{Labels for the x and y axes.} \item{xat,yat}{Where to place the ticks and tick labels on the axes.} \item{xaxlab,yaxlab}{Tick labels for the x and y axes.} \item{xcex,ycex}{Character expansions for the axis tick labels.} \item{xlas,ylas}{Orientation for the axis tick labels (see \samp{par}).} \item{xgrid,ygrid}{Whether to display a grid along the x or y direction.} \item{mar}{Margins for the plot (see Details).} \item{boxit}{Whether to draw a box around the plot.} \item{add}{Whether to draw a new plot (FALSE) or add symbols to an existing plot (TRUE).} \item{...}{Additional arguments passed to \samp{plot}.} } \details{ \samp{size_n_color} plots circles centered on the \samp{x} and \samp{y} coordinates. The size and color of the circles may also be specified individually, allowing four dimensions of variation to be displayed on the plot. \samp{size_n_color} may also be used to display a "visual table" as in the second example. Here the x and y coordinates are used to associate the symbols with two categorical variables, underlying cause of death and year of observation. If the x values are not passed to the function, it will try to space out the circles evenly in a representation of the matrix. If the matrix is not square, use a plotting device that has about the same proportion of height and width as the matrix. } \value{nil} \keyword{misc} \author{Jim Lemon} \seealso{\link{plot}, \link{points}, \link{par}} \examples{ meantemp<-c(19,22,25,29,21,20,16,27,23,26) totalrain<-c(174,152,196,120,177,183,92,153,161,85) numpumpkin<-c(53,47,61,63,38,42,48,71,66,29) meanwt<-c(1.5,2.3,2.8,1.9,2.4,1.8,2.6,2.2,1.7) size_n_color(meantemp,totalrain,meanwt/5,NA,xlim=c(15,30), color.scale(numpumpkin,c(0.8,0),c(0.8,1),0), xlab="Temperature (degrees C)",ylab="Rainfall (mm)", main="Number and weight of pumpkins by temperature and rainfall", xat=seq(15,30,by=5),yat=seq(80,200,by=20)) color.legend(15,60,18.5,60,seq(40,70,by=10), rect.col=color.scale(seq(40,70,by=10),c(0.8,0),c(0.8,1),0)) points(15:18,rep(126,4),cex=seq(1.5,3.0,by=0.5)) text(15:19,rep(134,5),c("1.5","2.0","2.5","3.0","kg")) par(xpd=TRUE) text(13.5,55,"Number of\npumpkins") par(xpd=FALSE) # now display a "visual table" of delayed registrations by underlying cause of # death and year of observation. The sizes of the circles represent the log of # the number of deaths and the colors represent the percentage of deaths that # occurred in the year prior to registration or earlier data(death_reg) size_n_color(x=matrix(rep(1996:2010,each=22),nrow=22), y=matrix(rep(1:22,15),nrow=22),size=t(death_reg[[1]])/200, col=color.scale(t(death_reg[[2]]),c(0,0.8,1),c(1,0.2,0),0), ylim=c(1,22),main="Delayed registrations by ICD chapter", xlab="Year",xaxlab=1996:2010,xat=1996:2010,xcex=0.8, yaxlab=colnames(death_reg[[1]]),ycex=0.8,ygrid=TRUE,mar=c(5,6,4,2)) color.legend(1994,-3.5,2000,-2.5,seq(0,50,by=10),cex=0.8, rect.col=color.scale(seq(0,50,by=10),c(0,0.8,1),c(1,0.2,0),0)) par(xpd=TRUE) text(1993.4,-2.5,"Pct.\nslow",cex=0.8) par(xpd=FALSE) } plotrix/man/ruginv.Rd0000644000176000001440000000213011641054015014350 0ustar ripleyusers\name{ruginv} \alias{ruginv} \title{Add an Inverse Rug to a Plot} \description{Adds a \emph{rug} representation (1D plot) of the data to the plot, but with the coloring inverted.} \usage{ ruginv(x,ticksize=0.03,side=1,lwd=0.5,col=par("fg"),col.ticks="white", quiet=getOption("warn") < 0,...) } \arguments{ \item{x}{A numeric vector.} \item{ticksize}{The length of the ticks making up the 'rug'. Positive lengths produce inward ticks.} \item{side}{On which side of the plot box the rug will appear. Usually 1 (bottom) or 3 (top).} \item{lwd}{The line width of the ticks.} \item{col}{Color of the background of the ticks.} \item{col.ticks}{The color of the ticks.} \item{quiet}{Logical indicating if there should be a warning about clipped values.} \item{...}{Further arguments passed to \link{polygon} when plotting the background for the ticks.} } \author{Peter Solymos} \seealso{\link{rug}} \examples{ require(stats) plot(density(faithful$eruptions,bw=0.15)) ruginv(faithful$eruptions,ticksize=-0.05) ruginv(jitter(faithful$eruptions,amount=0.01),side=3,col="lightblue") } \keyword{misc} plotrix/man/revaxis.Rd0000755000176000001440000000246111334502340014527 0ustar ripleyusers\name{revaxis} \alias{revaxis} \title{ Plot with axis direction(s) reversed } \description{ Reverses the sense of either or both the \samp{x} and \samp{y} axes. } \usage{ revaxis(x, y, xrev=FALSE, yrev=TRUE, xside=if (yrev) 3 else 1, yside=if (xrev) 4 else 2, xlab=NULL, ylab=NULL, bty=NULL, ...) } \arguments{ \item{x}{ Vector of \samp{x}-coordinates of the data to be plotted. } \item{y}{ Vector of \samp{y}-coordinates of the data to be plotted. } \item{xrev}{ Logical scalar; should the sense of the \samp{x}-axis be reversed?} \item{yrev}{ Logical scalar; should the sense of the \samp{y}-axis be reversed?} \item{xside}{ The side of the plot on which the \samp{x}-axis labels should go.} \item{yside}{ The side of the plot on which the \samp{y}-axis labels should go.} \item{xlab}{ Character string for labelling the \samp{x}-axis. } \item{ylab}{ Character string for labelling the \samp{y}-axis. } \item{bty}{ Single letter indicating the type of box to be drawn around the plot. See \link{par} for the possible letters and their meaning.} \item{\dots}{ Other arguments to be passed to plot.} } \value{ nil } \author{Rolf Turner} \seealso{ \link{plot}, \link{box}, \link{par}} \examples{ x <- runif(20) y <- runif(20) revaxis(x,y,yside=4) } \keyword{ hplot } plotrix/man/rescale.Rd0000755000176000001440000000210311334502324014457 0ustar ripleyusers\name{rescale} \title{Scale numbers into a new range} \description{Scale a vector or matrix of numbers into a new range.} \usage{ rescale(x,newrange) } \alias{rescale} \arguments{ \item{x}{A numeric vector, matrix or data frame.} \item{newrange}{The minimum and maximum value of the range into which \samp{x} will be scaled.} } \details{ \samp{rescale} performs a simple linear conversion of \samp{x} into the range specified by \samp{newrange}. Only numeric vectors, matrices or data frames with some variation will be accepted. NAs are now preserved - formerly the function would fail. } \value{On success, the rescaled object, otherwise the original object.} \author{Jim Lemon} \examples{ # scale one vector into the range of another normal.counts<-rnorm(100) normal.tab<-tabulate(cut(normal.counts,breaks=seq(-3,3,by=1))) normal.density<-rescale(dnorm(seq(-3,3,length=100)),range(normal.tab)) # now plot them plot(c(-2.5,-1.5,-0.5,0.5,1.5,2.5),normal.tab,xlab="X values", type="h",col="green") lines(seq(-3,3,length=100),normal.density,col="blue") } \keyword{misc} plotrix/man/rectFill.Rd0000755000176000001440000000234211732544445014626 0ustar ripleyusers\name{rectFill} \alias{rectFill} \title{Draw a rectangle filled with symbols} \description{ Draws a rectangle on the current figure filled with arbitrary symbols. } \usage{ rectFill(x1,y1,x2,y2,fg=par("fg"),bg=par("bg"),xinc=NA,yinc=NA, pch=1,pch.cex=1,pch.col=par("fg"),...) } \arguments{ \item{x1,y1,x2,y2}{Rectangle limits as in \samp{rect}.} \item{fg}{Foreground color} \item{bg}{Background color} \item{xinc,yinc}{The x and y increments of spacing for the symbols.} \item{pch}{Which symbol to use} \item{pch.cex}{Character expansion for the symbols.} \item{pch.col}{Color(s) for the symbols. } \item{...}{Additional arguments to \samp{points} for the symbols.} } \details{ \samp{rectFill} draws a rectangle and fills the rectangle with the symbols requested. It is probably most useful as a substitute for fill colors in a black and white environment. } \value{ nil } \author{Jim Lemon} \seealso{\link{rect}, \link{points}} \examples{ plot(1:7,type="n",xlab="",ylab="",main="Test of rectFill") rectFill(1:6,1:6,2:7,2:7,bg=2:7,pch=c("+","*","o",".","#","^"), xinc=c(0.2,0.1,0.2,0.1,0.2,0.2),yinc=c(0.2,0.1,0.2,0.1,0.2,0.2), pch.col=1:6) barp(matrix(runif(9),nrow=3),main="Black and white bar plot",pch=1:3) } \keyword{misc} plotrix/man/raw.means.plot.Rd0000644000176000001440000003275711747474615015753 0ustar ripleyusers\name{raw.means.plot} \alias{raw.means.plot} \alias{raw.means.plot2} \title{ raw.means.plot: Raw-Means Plots for Experimental Designs } \description{ raw.means.plot is a function for visualizing results of experimental designs with up to two factors. It plots both raw data (background) and factor/cell means (foreground) to provide a more accurate visualization of the underlying distribution. } \usage{ raw.means.plot(data, col.offset = 2, col.x = 3, col.value = 4, na.rm = FALSE, avoid.overlap = c("y", "x", "both"), y.factor = 1, y.amount = NULL, x.amount = 0.05, pch = 21:25, lty = 1:5, bg.b.col = "darkgrey", bg.f.col = NULL, fg.b.col = "black",fg.f.col = "black", type = "o", pt.cex = 1, lwd = 1, xlab = "", ylab = "", ylim, max.offset = 0.2, xaxis = TRUE, x.labels, xaxt = "n", plot = TRUE, legend = TRUE, mar = NULL, reset.mar = TRUE, l.pos, yjust = 0.5, l.bty = "n", l.adj = c(0, 0.5), ...) raw.means.plot2(data, col.id, col.offset, col.x, col.value, fun.aggregate = "mean", ...) } \arguments{ \item{data}{ a \code{data.frame} in long format (i.e., each datapoint one row, see \code{\link{reshape}} or the reshape package) that contains at least three columns: one column coding the first factor (\code{col.offset}), one column coding the second factor (\code{col.x}), and one column containing the values (\code{col.value}). } \item{col.id}{ a \code{character} scalar, specifiying the name of the column specifying the id column. (only for \code{raw.means.plot2}) } \item{col.offset}{ a \code{character} or \code{numeric} (only \code{raw.means.plot}) scalar, specifiying either name or number of the column coding the different lines (the offset or first factor). } \item{col.x}{ a \code{character} or \code{numeric} (only \code{raw.means.plot}) scalar, specifiying either name or number of the column coding the x-axis factor. Default is 3. } \item{col.value}{ a \code{character} or \code{numeric} (only \code{raw.means.plot}) scalar, specifiying either name or number of the data column. Default is 4. } \item{na.rm}{ \code{logical} indicating whether \code{NA} values should be stripped before the computation proceeds. Default is \code{FALSE}. Throws an error message if FALSE and NAs are encountered. } \item{avoid.overlap}{ character. What should happen to datapoints within one cell of the two factors that have the same value. \itemize{ \item \code{"y"} (the default) \code{\link{jitter}} is added so that overlapping points are distinguishable on the \strong{y}-axis \item \code{"x"} \code{\link{jitter}} is added so that overlapping points are distinguishable on the \strong{x}-axis \item \code{"both"} \code{\link{jitter}} is added so that overlapping points are distinguishable on both the \strong{y}- and the \strong{x}-axis. \item anything else. No jitter is added. } } \item{y.factor}{ \code{factor} for controlling the amount of jitter on the y-axis (will be passed to \code{\link{jitter}}). } \item{y.amount}{ \code{amount} for controlling the amount of jitter on the y-axis (will be passed to \code{\link{jitter}}). } \item{x.amount}{ \code{amount} for controlling the amount of jitter on the x-axis (will be passed to \code{\link{jitter}}). } \item{pch}{ \code{pch} values (plot symbols) taken for plotting the data. Note that the same values are taken for raw data and means. see \code{\link{points}} for more details. Recycled if too short (with warning). Default is 21:25, because those are the only values that can be displayed filled and non-filled. All other values should not be used. } \item{lty}{ \code{lty} values (line types) for connecting the means. See \code{\link{par}} for more details. Recycled if too short (with warning). Default is 1:5. } \item{bg.b.col}{ background border color: border color of raw data points. Default: \code{"darkgrey"} } \item{bg.f.col}{ background filling color: fill color of raw data points. Default: \code{NULL} } \item{fg.b.col}{ foreground border color: border color of mean data points. Default: \code{black} } \item{fg.f.col}{ foreground fill color: fill color for mean data points. Default: \code{black} } \item{type}{ same as type in \code{\link{plot}}. Default: \code{o} ("overplotted") } \item{pt.cex}{ \code{numeric} specifying the \code{cex} value used for plotting the points. Default is 1. } \item{lwd}{ \code{numeric} specifying the \code{lwd} value used for plotting the lines. Default is 1. } \item{xlab}{ x-axis label. Default: \code{""} } \item{ylab}{ y-axis label. Default: \code{""} } \item{ylim}{ the y-axis limits of the plot. If not specified (the default) will be taken from data so that all raw data points are visible and a warning message is displayed specifying the ylim. } \item{max.offset}{ \code{numeric}. maximal offset of factor levels from the offset factor (\code{col.offset}) specifying the different lines. The centre of each factor on the x-axis is at full numbers (starting from 1 to ...). The maximum will only be reached if the number of factor levels (from \code{col.offset}) is even. Default: 0.2. } \item{xaxis}{ \code{logical} value indicating whether or not the x-axis should be generated by \code{raw.means.plot}. If \code{TRUE}, labels for the x-axis will be taken either from the unique values of \code{col.x} or can be specified with \code{x.labels}. } \item{x.labels}{ \code{character} vector specifiying \code{col.x} levels. Only relevant if \code{xaxis=TRUE}. Then, the values given here will be displayed at the x-axis for each factor level of \code{col.x}. } \item{xaxt}{ A character which specifies whether ot not the x-axis should be plotted by the call to plot function. Interfers with the aforementioned \code{xaxis} argument and the automatic \code{xaxis} function by \code{raw.means.plot}. Just there for completeness. Default \code{"n"} (and should not be changed). } \item{plot}{ \code{logical}. Should the \code{raw.means.plot} be drawn or not. If \code{TRUE} (the default) plot will be drawn. If \code{FALSE} only the legend will be drawn (if \code{legend = TRUE}) See details. } \item{legend}{ \code{logical} indicating whether or not \code{raw.means.plot} should automatically add a legend on the right outside the plot area indicating which line and points refer to which \code{col.offset} factor levels. Default is \code{TRUE}. } \item{mar}{ \code{NULL} or \code{numerical} vector of length 4 indicating the margins of the plot (see \code{\link{par}}). If \code{NULL} (the default) the right margin (i.e., \code{par("mar")[4]}) will be (imperfectly) guessed from the \code{col.offset} factors for placing the legend right to the plot. If length is four this value will be taken. Ignored for \code{plot = FALSE}. } \item{reset.mar}{ \code{logical} indicating if the margins (\code{mar}) shall be resetted after setting internally. Will be ignored if \code{legend = FALSE}. Default is \code{TRUE} and should not be changed (especially with \code{plot = FLASE}). } \item{l.pos}{ \code{numeric} vector of length 2 indicating the position of the legend. If not specified automatically determined. See details. } \item{yjust}{ how the legend is to be justified relative to the legend y location. A value of 0 means top, 0.5 means centered and 1 means bottom justified. Default is 0.5. } \item{l.bty}{ the type of box to be drawn around the legend. The allowed values are \code{"o"} and \code{"n"} (the default). } \item{l.adj}{ \code{numeric} of length 1 or 2; the string adjustment for legend text. Useful for y-adjustment when labels are plotmath expression. see \code{\link{legend}} and \code{\link{plotmath}} for more info. } \item{\dots}{ further arguments which are either passed to plot or legend (or \code{raw.means.plot} for \code{raw.means.plot2}). The following argumenst are passed to legend, all others are passed to plot:\cr \code{"fill", "border", "angle", "density", "box.lwd", "box.lty", "box.col", "pt.cex", "pt.lwd", "xjust", "x.intersp", "y.intersp", "text.width", "text.col", "merge", "trace", "plot", "ncol", "horiz", "title", "inset", "title.col", "title.adj"} } \item{fun.aggregate}{ Function or function name used for aggregating the data across the trwo factors. Default is \code{"mean"}. (only for \code{raw.means.plot2}) } } \details{ \code{raw.means.plot2} is probably the more useful function, as it allows for using a data.frame with more than two-factors and aggregates across the other factors, but needs a column specifiying the experimental unit (e.g., participant). \code{raw.means.plot} is basically an advanced wrapper for two other functions: \code{\link{plot}} and (if \code{legend=TRUE}) \code{\link{legend}}. Furthermore, raw data is plotted with a call to \code{\link{points}} and the means with a call to \code{\link{lines}}. You can use \code{raw.means.plot} to plot only a legend by setting \code{plot = FALSE} and \code{legend = TRUE}. Then, \code{raw.means.plot} will draw an invisible plot with \code{xlim = c(0,10)} and \code{ylim = c(0, 10)} and place the legend on this invisible plot. You can specify \code{l.pos} to position the legend, otherwise it will be plotted at \code{c(5,5)} (i.e., in the middle of the plot). Note that \code{xpd = TRUE} in the call to \code{legend} (see \code{link{par}}). } \value{ Nothing. This function is invoked for its side effects. } \references{ see \url{http://www.psychologie.uni-freiburg.de/Members/singmann/R/rm.plot} } \author{ Henrik Singmann (\email{henrik.singmann@psychologie.uni-freiburg.de}) with ideas from Jim Lemon } \seealso{ \code{\link{add.ps}} can be used in addition to\code{raw.means.plot} to compare the factors at each x-axis position, by adding p-values from t-tests to the x-axis. } \examples{ x <- data.frame(id = 1:150, offset = rep(c("Group A", "Group B", "Group C"),each = 50), xaxis = sample(c("A", "B", "C", "D"),150, replace = TRUE), data = c(rnorm(50, 10, 5), rnorm(50, 15,6), rnorm(50, 20, 5))) raw.means.plot(x) raw.means.plot(x, main = "Example", ylab = "Values", xlab = "Factor", title = "Groups") raw.means.plot(x, "offset", "xaxis", "data") raw.means.plot(x, "xaxis", "offset", "data") raw.means.plot(x, 3, 2, 4) x2 <- data.frame(id = 1:150, offset = rep(c("Group A", "Group B", "Group C"),each = 50), xaxis = sample(c("A", "B", "C", "D"),150, replace = TRUE), data = c(rnorm(50, 10, 5), rnorm(50, 15,6), rnorm(50, 20, 5))) layout(matrix(c(1,2,3,3), 2,2,byrow = TRUE), heights = c(7,1)) raw.means.plot(x, main = "Data x1", ylab = "Values", xlab = "Factor", legend = FALSE, mar = c(4,4,4,1)+0.1) raw.means.plot(x2, main = "Data x2", ylab = "Values", xlab = "Factor", legend = FALSE, mar = c(4,4,4,1)+0.1) raw.means.plot(x2, plot = FALSE, title = "Groups") y <- data.frame(id = 1:300, offset = rep(1, 300), axis = sample(LETTERS[1:6],300, replace = TRUE), data = c(rnorm(100, 1), rnorm(100), rnorm(100,1))) par(mfrow = c(2,2)) raw.means.plot(y, legend = FALSE) raw.means.plot(y, type = "p", legend = FALSE) raw.means.plot(y, type = "l", legend = FALSE) raw.means.plot(y, 3, 2, x.labels = "one group only") # Example with overlapping points z <- data.frame (id = 1:200, offset = rep(c("C 1", "C 2"), 200), axis = sample(LETTERS[1:4], 200, replace = TRUE), data = sample(1:20, 200, replace = TRUE)) # x versus y jitter par(mfrow = c(2,2)) raw.means.plot(z, avoid.overlap = "none", main = "no-jitter") raw.means.plot(z, main = "y-axis jitter (default)") raw.means.plot(z, avoid.overlap = "x", main = "x-axis jitter") raw.means.plot(z, avoid.overlap = "both", main = "both-axis jitter") # y-axis jitter (default) par(mfrow = c(2,2)) raw.means.plot(z, avoid.overlap = "none", main = "no jitter") raw.means.plot(z, y.factor = 0.5, main = "smaller y-jitter") raw.means.plot(z, main = "standard y-jitter") raw.means.plot(z, y.factor = 2, main = "bigger y-jitter") # x-axis jitter (default) par(mfrow = c(2,2)) raw.means.plot(z, avoid.overlap = "none", main = "no jitter") raw.means.plot(z, avoid.overlap = "x", x.amount = 0.025, main = "smaller x -jitter") raw.means.plot(z, avoid.overlap = "x", main = "standard x-jitter") raw.means.plot(z, avoid.overlap = "x", x.amount= 0.1, main = "bigger x-jitter") \dontrun{ #The examples uses the OBrienKaiser dataset from car and needs reshape. require(reshape) require(car) data(OBrienKaiser) OBKnew <- cbind(factor(1:nrow(OBrienKaiser)), OBrienKaiser) colnames(OBKnew)[1] <- "id" OBK.long <- melt(OBKnew) OBK.long[, c("measurement", "time")] <- t(vapply(strsplit(as.character(OBK.long$variable), "\\\."), "[", c("", ""))) raw.means.plot2(OBK.long, "id", "measurement", "gender", "value") raw.means.plot2(OBK.long, "id", "treatment", "gender", "value") # also use add.ps: # For this example the position at each x-axis are within-subject comparisons! raw.means.plot2(OBK.long, "id", "measurement", "gender", "value") add.ps(OBK.long, "id", "measurement", "gender", "value", paired = TRUE) #reference is "fup" raw.means.plot2(OBK.long, "id", "measurement", "gender", "value") add.ps(OBK.long, "id", "measurement", "gender", "value", ref.offset = 2, paired = TRUE) #reference is "post" # Use R's standard (i.e., Welch test) raw.means.plot2(OBK.long, "id", "treatment", "gender", "value") add.ps(OBK.long, "id", "treatment", "gender", "value", prefixes = c("p(control vs. A)", "p(control vs. B)")) # Use standard t-test raw.means.plot2(OBK.long, "id", "treatment", "gender", "value") add.ps(OBK.long, "id", "treatment", "gender", "value", var.equal = TRUE, prefixes = c("p(control vs. A)", "p(control vs. B)")) } } plotrix/man/radialtext.Rd0000644000176000001440000000614611762341206015217 0ustar ripleyusers\name{radialtext} \alias{radialtext} \title{Display text in a radial line} \description{ Displays a string in a radial line, rotating it to flow in the radial direction and optionally scaling each letter's size according to its distance from the center. } \usage{ radialtext(x, center=c(0,0), start=NA, middle=1, end=NA, angle=0, deg=NA, expand=0, stretch=1, nice=TRUE, cex=NA, ...) } \arguments{ \item{x}{A character string.} \item{center}{The center of the circular area in x/y user units.} \item{start}{The starting distance of the string from the center in x/y user units.} \item{middle}{The middle distance of the string from the center in x/y user units.} \item{end}{The ending distance of the string from the center in x/y user units.} \item{angle}{The angular position of the string in radians.} \item{deg}{The angular position of the string in degrees (takes precedence if not NA).} \item{expand}{Size expansion factor for characters, used only if \samp{start} specified.} \item{stretch}{How much to stretch the string for appearance, 1 for none.} \item{nice}{TRUE to auto-flip text to keep it upright, FALSE to let it be upside down.} \item{cex}{The overall character expansion factor, NA for par("cex").} \item{...}{Additional arguments passed to \samp{text}.} } \value{nil} \details{ This may not work on all devices, as not all graphic devices can rotate text to arbitrary angles. The output looks best on a Postscript or similar device that can rotate text without distortion. Rotated text often looks very ragged on small bitmaps. If the user passes a value for \samp{start}, this will override a value for \samp{middle} or \samp{end}. Likewise, a value for \samp{end} will override a value for \samp{middle}. Also, a value for \samp{deg} overrides any value passed to \samp{angle}. If \samp{expand} is 0, all characters will be the same size, while a value of 1 will scale characters so that one that is twice as far from the center will be twice as large. Negative values are permitted too, but \samp{expand} is only used if \samp{start} was specified. } \author{Ted Toal} \seealso{\link{text}, \link{arctext}} \examples{ plot(0, xlim=c(1,5), ylim=c(1,5), main="Test of radialtext", xlab="", ylab="", type="n") points(3, 3, pch=20) radialtext("uncooked spaghetti", center=c(3,3), col="blue") radialtext("uncooked spaghetti", center=c(3,3), start=1.2, angle=pi/4, cex=0.8) radialtext("uncooked spaghetti", center=c(3,3), middle=1.2, angle=pi/4+0.1, cex=0.8) radialtext("uncooked spaghetti", center=c(3,3), end=1.2, angle=pi/4+0.2, cex=0.8) radialtext("uncooked spaghetti", center=c(3,3), start=0.5, deg=135, cex=0.8, col="green") radialtext("uncooked spaghetti", center=c(3,3), start=0.5, deg=145, cex=0.8, stretch=2) radialtext("uncooked spaghetti", center=c(3,3), start=0.5, deg=20, expand=0, col="red") radialtext("uncooked spaghetti", center=c(3,3), start=0.5, deg=250, expand=0.35) radialtext("uncooked spaghetti", center=c(3,3), start=0.75, deg=225, expand=1, col="gold") radialtext("uncooked spaghetti", center=c(3,3), start=0.5, deg=325, expand=-0.25, cex=2) } \keyword{misc} plotrix/man/radial.plot.labels.Rd0000755000176000001440000000432611371507244016533 0ustar ripleyusers\name{radial.plot.labels} \title{Display labels on a circular grid} \usage{ radial.plot.labels(lengths,radial.pos=NULL,units="radians",radial.lim=NULL, start=0,clockwise=FALSE,labels,adj=NULL,pos=NULL,...) } \alias{radial.plot.labels} \arguments{ \item{lengths}{numeric data vector. Magnitudes will be represented as the radial positions of symbols, line ends or polygon vertices.} \item{radial.pos}{numeric vector of radial positions. These will be converted to radians if the \samp{units} argument is not "radians".} \item{units}{The units of \samp{radial.pos} may be degrees or 24 hour clock positions. If \samp{units} is "polar" or "clock24" respectively, the values of radial.pos will be converted into radians.} \item{radial.lim}{Optional radial limits for the circular plot. These must be the same as the radial limits of the original plot.} \item{start}{The zero position on the plot in the units of \samp{radial.pos}.} \item{clockwise}{Whether to increase angles clockwise rather than the default counterclockwise.} \item{labels}{text labels to display on the plot.} \item{adj}{Text justification as in the \samp{text} function.} \item{pos}{Text position as in the \samp{text} function.} \item{...}{additional arguments passed to \samp{text}.} } \description{ \samp{radial.plot.labels} displays a labels on a circular plot produced by one of the radial.plot family of functions. } \details{ Don't confuse this function with the \samp{radial.labels} argument in the radial.plot function. This labels the values rather than the grid. } \value{nil} \author{Jim Lemon} \keyword{misc} \seealso{\link{text}} \examples{ testlen<-c(rnorm(10)*2+5) # do the labels in clock24 units testpos<-c(6.74,8.3,10.55,12.33,13.75,15.9,17.15,19.36,21.02,23.27) oldpar<-clock24.plot(testlen,testpos,main="Test radial.plot.labels", rp.type="s",point.symbols=3,point.col="blue") radial.plot.labels(testlen,testpos,units="clock24",labels=LETTERS[1:10], pos=3,col="blue") testangle<-c(25,42,67,94,128,173,191,234,268,307) # now a polar plot polar.plot(testlen,testangle,main="Test radial.plot.labels",rp.type="p", poly.col="green") radial.plot.labels(testlen,testangle,units="polar",labels=LETTERS[1:10]) # reset par par(oldpar) } plotrix/man/radial.plot.Rd0000755000176000001440000002057112132121156015260 0ustar ripleyusers\name{radial.plot} \alias{radial.plot} \title{ Plot values on a circular grid of 0 to 2*pi radians } \description{ Plot numeric values as distances from the center of a circular field in the directions defined by angles in radians. } \usage{ radial.plot(lengths,radial.pos=NULL,labels,label.pos=NULL,radlab=FALSE, start=0,clockwise=FALSE,rp.type="r",label.prop=1.15,main="",xlab="",ylab="", line.col=par("fg"),lty=par("lty"),lwd=par("lwd"),mar=c(2,2,3,2), show.grid=TRUE,show.grid.labels=4,show.radial.grid=TRUE, grid.col="gray",grid.bg="transparent",grid.left=FALSE,grid.unit=NULL, point.symbols=NULL,point.col=NULL,show.centroid=FALSE,radial.lim=NULL, radial.labels=NULL,boxed.radial=TRUE,poly.col=NULL,add=FALSE,...) } \arguments{ \item{lengths}{A numeric data vector or matrix. If \samp{lengths} is a matrix, the rows will be considered separate data vectors.} \item{radial.pos}{A numeric vector or matrix of positions in radians. These are interpreted as beginning at the right (0 radians) and moving counterclockwise. If \samp{radial.pos} is a matrix, the rows must correspond to rows of \samp{lengths}.} \item{labels}{Character strings to be placed at the outer ends of the lines. If set to NA, will suppress printing of labels, but if missing, the radial positions will be used.} \item{label.pos}{The positions of the labels around the plot in radians.} \item{radlab}{Whether to rotate the outer labels to a radial orientation.} \item{start}{Where to place the starting (zero) point. Defaults to the 3 o'clock position.} \item{clockwise}{Whether to interpret positive positions as clockwise from the starting point. The default is counterclockwise.} \item{rp.type}{Whether to draw (r)adial lines, a (p)olygon, (s)ymbols or some combination of these. If \samp{lengths} is a matrix and rp.type is a vector, each row of \samp{lengths} can be displayed differently.} \item{label.prop}{The label position radius as a proportion of the maximum line length.} \item{main}{The title for the plot.} \item{xlab,ylab}{Normally x and y axis labels are suppressed.} \item{line.col}{The color of the radial lines or polygons drawn.} \item{lty}{The line type(s) to be used for polygons or radial lines.} \item{lwd}{The line width(s) to be used for polygons or radial lines.} \item{mar}{Margins for the plot. Allows the user to leave space for legends, long labels, etc.} \item{show.grid}{Logical - whether to draw a circular grid.} \item{show.grid.labels}{Whether and where to display labels for the grid - see Details.} \item{show.radial.grid}{Whether to draw radial lines to the plot labels.} \item{grid.col}{Color of the circular grid.} \item{grid.bg}{Fill color of above.} \item{grid.left}{Whether to place the radial grid labels on the left side.} \item{grid.unit}{Optional unit description for the grid.} \item{point.symbols}{The symbols for plotting (as in pch).} \item{point.col}{Colors for the symbols.} \item{show.centroid}{Whether to display a centroid.} \item{radial.lim}{The range of the grid circle. Defaults to \samp{pretty(range(lengths))}, but if more than two values are passed, the exact values will be displayed.} \item{radial.labels}{Optional labels for the radial grid. The default is the values of radial.lim.} \item{boxed.radial}{Whether to use boxed.labels or text for radial labels.} \item{poly.col}{Fill color if polygons are drawn. Use NA for no fill.} \item{add}{Whether to add one or more series to an existing plot.} \item{...}{Additional arguments are passed to \samp{plot}.} } \value{ The \samp{par} values that are changed in the function as they were at the time \samp{radial.plot} was called. } \details{ \samp{radial.plot} displays a plot of radial lines, polygon(s), symbols or a combination of these centered at the midpoint of the plot frame, the lengths, vertices or positions corresponding to the numeric magnitudes of the data values. If \samp{show.centroid} is TRUE, an enlarged point at the centroid of values is displayed. The centroid is calculated as the average of x and y values unless \samp{rp.type="p"}. In this case, the barycenter of the polygon is calculated. Make sure that these suit your purpose, otherwise calculate the centroid that you really want and add it with the \samp{points} function. Note that if the observations are not taken at equal intervals around the circle, the centroid may not mean much. If the user wants to plot several sets of lines, points or symbols by passing matrices or data frames of \samp{lengths} and \samp{radial.pos}, remember that these will be grouped by row, so transpose if the data are grouped by columns. If more series are added to an existing plot, \samp{radial.plot} will try to maintain the current plot parameters. Resetting the parameters after doing the initial plot will almost certainly mess up any series that are added. Series that are added will be plotted "on top" of the existing plot, possibly overplotting other things. If the added series have a larger range than the initial series, set \samp{radial.lim} to account for this in the initial plot, and if \samp{radial.lim} is specified in the initial plot, remember to repeat it for added series as in the example. The size of the labels on the outside of the plot can be adjusted by setting \samp{par(cex.axis=)} and that of the labels inside by setting \samp{par(cex.lab=)}. If \samp{radlab} is TRUE, the labels will be rotated to a radial alignment. This may help when there are many values and labels. If some labels are still crowded, try running \samp{label.pos} through the \samp{spreadout} function. If the \samp{show.grid.labels} argument is a number from 1 to 4, the labels will be placed along a horizontal or vertical radius. The numbers represent the same positions as in \samp{axis}, with the default (4) on the right. The radial.plot family of plots is useful for illustrating cyclic data such as wind direction or speed (but see \samp{oz.windrose} for both), activity at different times of the day, and so on. While \samp{radial.plot} actually does the plotting, another function is usually called for specific types of cyclic data. } \author{Jim Lemon - thanks to Jeremy Claisse and Antonio Hernandez Matias for the \samp{lty} and \samp{rp.type} suggestions respectively, Patrick Baker for the request that led to \samp{radlab}, Thomas Steiner for the request for the \samp{radial.lim} and \samp{radial.labels} modifications, Evan Daugharty for requesting the \samp{add} argument, James MacCarthy for requesting better radial labels, Steve Ellison for noticing that the return values of the functions had changed and Don Dennerline for requesting the rank clock.} \seealso{\link{polar.plot},\link{clock24.plot}} \examples{ testlen<-runif(10,0,10) testpos<-seq(0,18*pi/10,length=10) testlab<-letters[1:10] oldpar<-radial.plot(testlen,testpos,main="Test Radial Lines",line.col="red",lwd=3) testlen<-c(sin(seq(0,1.98*pi,length=100))+2+rnorm(100)/10) testpos<-seq(0,1.98*pi,length=100) radial.plot(testlen,testpos,rp.type="p",main="Test Polygon",line.col="blue") # now do a 12 o'clock start with clockwise positive radial.plot(testlen,testpos,start=pi/2,clockwise=TRUE, rp.type="s",main="Test Symbols (clockwise)", point.symbols=16,point.col="green",show.centroid=TRUE) # one without the circular grid and multiple polygons # see the "diamondplot" function for variation on this posmat<-matrix(sample(2:9,30,TRUE),nrow=3) radial.plot(posmat,labels=paste("X",1:10,sep=""),rp.type="p", main="Spiderweb plot",line.col=2:4,show.grid=FALSE,lwd=1:3, radial.lim=c(0,10)) # dissolved ions in water ions<-c(3.2,5,1,3.1,2.1,4.5) ion.names<-c("Na","Ca","Mg","Cl","HCO3","SO4") radial.plot(ions,labels=ion.names,rp.type="p",main="Dissolved ions in water", grid.unit="meq/l",radial.lim=c(0,5),poly.col="yellow") # add points inside the polygon radial.plot(ions-0.4,rp.type="s",radial.lim=c(0,5), point.symbols=4,point.col="red",add=TRUE) radmat<-matrix(c(sample(1:4,4),sample(1:4,4),sample(1:4,4),sample(1:4,4), sample(1:4,4),sample(1:4,4),sample(1:4,4),sample(1:4,4), sample(1:4,4),sample(1:4,4)),nrow=4) # finally a rank clock radial.plot(radmat,rp.type="l",radial.pos=seq(0,20*pi/11.1,length.out=10), label.pos=seq(0,20*pi/11.1,length.out=10),start=pi/2,clockwise=TRUE, labels=2001:2010,radial.lim=c(0.2,4),main="Rank clock") par(xpd=oldpar$xpd,mar=oldpar$mar,pty=oldpar$pty) # reset the margins par(mar=c(5,4,4,2)) } \keyword{misc} plotrix/man/radial.pie.Rd0000644000176000001440000001173611631125742015067 0ustar ripleyusers\name{radial.pie} \alias{radial.pie} \title{ Plot sectors/annuli on a circular grid of 0 to 2*pi radians } \description{ Plot numeric values as sectors with optional annuli on a circular field in the directions defined by angles in radians. } \usage{ radial.pie(radial.extents,sector.edges=NULL, sector.colors=NULL,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1), alpha=1,labels=NA,label.pos=NULL,radlab=FALSE,start=0, clockwise=FALSE,label.prop=1.15,radial.lim=NULL,main="",xlab="",ylab="", mar=c(2,2,3,2),show.grid=TRUE,show.grid.labels=4,show.radial.grid=TRUE, grid.col="gray",grid.bg="transparent",grid.left=FALSE,grid.unit=NULL, radial.labels=NULL,boxed.radial=TRUE,add=FALSE,...) } \arguments{ \item{radial.extents}{A numeric data vector or list. If \samp{radial.extents} is a list, the elements of the list will be considered separate data vectors.} \item{sector.edges}{A numeric vector of positions in radians. These are interpreted as beginning at the right (0 radians) and moving counterclockwise unless \samp{clockwise} is TRUE.} \item{sector.colors}{Optional colors for the sectors and annuli. Defaults to \samp{rainbow(nsectors)} with fading outward if annuli are specified.} \item{cs1, cs2, cs3, alpha}{Color scaling arguments - see \link{color.scale}.} \item{labels}{Character strings to be placed at the outer ends of the lines. If set to NA, will suppress printing of labels, but if missing, the radial positions will be used.} \item{label.pos}{The positions of the labels around the plot in radians.} \item{radlab}{Whether to rotate the outer labels to a radial orientation.} \item{start}{Where to place the starting (zero) point. Defaults to the 3 o'clock position.} \item{clockwise}{Whether to interpret positive positions as clockwise from the starting point. The default is counterclockwise.} \item{label.prop}{The label position radius as a proportion of the maximum line length.} \item{radial.lim}{The inner and outer radial limits for the plot. Defaults to the range of radial.extents, although zero to \samp{max(radial.extents)} is often what is wanted.} \item{main}{The title for the plot.} \item{xlab,ylab}{Normally x and y axis labels are suppressed.} \item{mar}{Margins for the plot. Allows the user to leave space for legends, long labels, etc.} \item{show.grid}{Logical - whether to draw a circular grid.} \item{show.grid.labels}{Whether and where to display labels for the grid - see Details.} \item{show.radial.grid}{Whether to draw radial lines to the plot labels.} \item{grid.col}{Color of the circular grid.} \item{grid.bg}{Fill color of above.} \item{grid.left}{Whether to place the radial grid labels on the left side.} \item{grid.unit}{Optional unit description for the grid.} \item{radial.labels}{Optional labels for the radial grid. The default is the values of radial.lim.} \item{boxed.radial}{Whether to use boxed.labels or text for radial labels.} \item{add}{Whether to add one or more series to an existing plot.} \item{...}{Additional arguments are passed to \samp{plot}.} } \value{ The \samp{par} values that are changed in the function as they were at the time \samp{radial.pie} was called. } \details{ \samp{radial.pie} displays a plot of radial sectors with optional annular sections centered at the midpoint of the plot frame, the lengths corresponding to the numeric magnitudes of \samp{radial.extents}. If more series are added to an existing plot, \samp{radial.pie} will try to maintain the current plot parameters. However, it seems unlikely that adding series would be sensible in \samp{radial.pie}. This argument may be dropped if it proves useless. The size of the labels on the outside of the plot can be adjusted by setting \samp{par(cex.axis=)} and that of the labels inside by setting \samp{par(cex.lab=)}. If \samp{radlab} is TRUE, the labels will be rotated to a radial alignment. This may help when there are many values and labels. If some labels are still crowded, try running \samp{label.pos} through the \samp{spreadout} function. If the \samp{show.grid.labels} argument is a number from 1 to 4, the labels will be placed along a horizontal or vertical radius. The numbers represent the same positions as in \samp{axis}, with the default (4) on the right. \samp{radial.pie} works somewhat differently from the \samp{radial.plot} family and is still under development. I have released it in order to get feedback to improve both the design and the programming. If successful, I hope to merge the code with the \samp{radial.plot} function. } \author{Jim Lemon - thanks to Patrick Jemison for asking for it.} \seealso{\link{radial.plot}} \examples{ pie1<-c(3,6,5,4,7,8,9,1,4) pie2<-list(0:3,1:6,2:5,1:4,0:7,4:8,2:9,0:1,0:4) pie3<-sample(10:60,36) pie4<-list(sort(sample(1:60,8))) for(sector in 2:36) pie4[[sector]]<-sort(sample(1:60,8)) oldpar<-radial.pie(pie1,labels=LETTERS[1:9]) radial.pie(pie2,labels=letters[2:10]) radial.pie(pie3,labels=1:36) radial.pie(pie4,labels=1:36) # restore the par values par(oldpar) } \keyword{misc} plotrix/man/radial.grid.Rd0000644000176000001440000000220411631137662015231 0ustar ripleyusers\name{radial.grid} \title{Display a radial grid} \usage{ radial.grid(labels=NA,label.pos=NULL,radlab=FALSE,radial.lim=NULL, start=0,clockwise=FALSE,label.prop=1.15,grid.pos, grid.col="gray",grid.bg="transparent") } \alias{radial.grid} \arguments{ \item{labels}{The labels to display around the circumference of the grid.} \item{label.pos}{Radial positions for the labels.} \item{radlab}{Whether to rotate the labels to a radial orientation.} \item{radial.lim}{Optional radial limits for the circular plot. If specified, these must be the same as the radial limits of the original plot.} \item{start}{The zero position on the plot in the units of \samp{label.pos}.} \item{clockwise}{Whether to increase angles clockwise rather than the default counterclockwise.} \item{label.prop}{Proportion of \samp{radial.lim} to place the labels.} \item{grid.pos}{Radial positions for the circular grid lines.} \item{grid.col}{Color for the radial grid lines.} \item{grid.bg}{Background color for the radial grid.} } \description{ \samp{radial.grid} displays a radial grid for the radial.pie function. } \value{nil} \author{Jim Lemon} \keyword{misc} plotrix/man/pyramid.plot.Rd0000755000176000001440000001362112132136161015471 0ustar ripleyusers\name{pyramid.plot} \alias{pyramid.plot} \title{Pyramid plot} \description{ Displays a pyramid (opposed horizontal bar) plot on the current graphics device. } \usage{ pyramid.plot(lx,rx,labels=NA,top.labels=c("Male","Age","Female"), main="",laxlab=NULL,raxlab=NULL,unit="\%",lxcol,rxcol,gap=1, ppmar=c(4,2,4,2),labelcex=1,add=FALSE,xlim,show.values=FALSE,ndig=1, do.first=NULL) } \arguments{ \item{lx,rx}{Vectors or a matrix or data frame (see Details) which should be of equal length.} \item{labels}{Labels for the categories represented by each pair of bars. There should be a label for each lx or rx value, even if empty. If \samp{labels} is a matrix or data frame, the first two columns will be used for the left and right category labels respectively.} \item{top.labels}{The two categories represented on the left and right sides of the plot and a heading for the labels in the center.} \item{main}{Optional title for the plot.} \item{laxlab}{Optional labels for the left x axis ticks.} \item{raxlab}{Optional labels for the right x axis ticks.} \item{unit}{The label for the units of the plot.} \item{lxcol,rxcol}{Color(s) for the left and right sets of bars. Both of these default to \samp{rainbow(length(labels))}.} \item{gap}{One half of the space between the two sets of bars for the \samp{labels} in user units.} \item{ppmar}{Margins for the plot (see Details).} \item{labelcex}{Expansion for the category labels.} \item{add}{Whether to add bars to an existing plot. Usually this involves overplotting a second set of bars, perhaps transparent.} \item{xlim}{Optional x limit for the plot (see Details).} \item{show.values}{Whether to display \samp{lx} and \samp{rx} at the ends of the bars.} \item{ndig}{The number of digits to round the values if displayed.} \item{do.first}{Optional expression to evaluate before displaying anything.} } \details{ \samp{pyramid.plot} is principally intended for population pyramids, although it can display other types of opposed bar charts with suitable modification of the arguments. If the user wants a different unit for the display, just change \samp{unit} accordingly. The default gap of two units is usually satisfactory for the four to six percent range of most bars on population pyramids. If \samp{labels} is a matrix or data frame of at least two columns, the first column will be displayed on the on the left side of the gap in the center, and the second on the right. This will almost always require increasing the gap width and perhaps also specifying a wider plotting device. Displaying the values will usually require increasing the left and/or right margins of the plot, or setting \samp{xlim} larger than the largest value. If a gap width of zero is passed, the category labels will be displayed at the left and right extents of the plot. This usually requires setting \samp{xlim} to values larger than the maximum extent of \samp{lx} and \samp{rx}. The user can pass two different values to \samp{xlim}, but this is almost always a bad idea, as the lengths of the bars will not be in the same proportion to the values on the left and right sides. Both the bars and category labels are vertically centered on integer values, allowing the user to easily add components to the plot. \samp{lx} and \samp{rx} are the values specifying the left and right extents of the left and right bars respectively. If both are matrices or data frames, \samp{pyramid.plot} will produce opposed stacked bars with the first columns innermost. In this mode, colors are limited to one per column. The stacked bar mode will in general not work with the \samp{add} method or with a gap of zero. Note that the stacked bar mode can get very messy very quickly. The \samp{add} argument allows one or more sets of bars to be plotted on an existing plot. If these are not transparent, any bar that is shorter than the bar that overplots it will disappear. Only some graphic devices (e.g. \samp{pdf}) will handle transparency. In order to add bars, the function cannot restore the initial margin values or the new bars will not plot properly. To automatically restore the plot margins, call the function as in the example. } \value{ The return value of \samp{par("mar")} when the function was called. } \author{Jim Lemon (thanks to Susumu Tanimura for the patch that omits ticks for NA values in vector input)} \seealso{\link{rect}} \examples{ xy.pop<-c(3.2,3.5,3.6,3.6,3.5,3.5,3.9,3.7,3.9,3.5,3.2,2.8,2.2,1.8, 1.5,1.3,0.7,0.4) xx.pop<-c(3.2,3.4,3.5,3.5,3.5,3.7,4,3.8,3.9,3.6,3.2,2.5,2,1.7,1.5, 1.3,1,0.8) agelabels<-c("0-4","5-9","10-14","15-19","20-24","25-29","30-34", "35-39","40-44","45-49","50-54","55-59","60-64","65-69","70-74", "75-79","80-44","85+") mcol<-color.gradient(c(0,0,0.5,1),c(0,0,0.5,1),c(1,1,0.5,1),18) fcol<-color.gradient(c(1,1,0.5,1),c(0.5,0.5,0.5,1),c(0.5,0.5,0.5,1),18) par(mar=pyramid.plot(xy.pop,xx.pop,labels=agelabels, main="Australian population pyramid 2002",lxcol=mcol,rxcol=fcol, gap=0.5,show.values=TRUE)) # three column matrices avtemp<-c(seq(11,2,by=-1),rep(2:6,each=2),seq(11,2,by=-1)) malecook<-matrix(avtemp+sample(-2:2,30,TRUE),ncol=3) femalecook<-matrix(avtemp+sample(-2:2,30,TRUE),ncol=3) # use a background color par(bg="#eedd55") # group by age agegrps<-c("0-10","11-20","21-30","31-40","41-50","51-60", "61-70","71-80","81-90","91+") oldmar<-pyramid.plot(malecook,femalecook,labels=agegrps, unit="Bowls per month",lxcol=c("#ff0000","#eeee88","#0000ff"), rxcol=c("#ff0000","#eeee88","#0000ff"),laxlab=c(0,10,20,30), raxlab=c(0,10,20,30),top.labels=c("Males","Age","Females"),gap=4) # put a box around it box() # give it a title mtext("Porridge temperature by age and sex of bear",3,2,cex=1.5) # stick in a legend legend(par("usr")[1],11,c("Too hot","Just right","Too cold"), fill=c("#ff0000","#eeee88","#0000ff")) # don't forget to restore the margins and background par(mar=oldmar,bg="transparent") } \keyword{misc} plotrix/man/ptext3d.Rd0000755000176000001440000000103411441423436014443 0ustar ripleyusers\name{ptext3d} \alias{ptext3d} \title{ Display text on a 3D plot } \description{ Display text on a 3D plot defined by a list of coordinates } \usage{ ptext3d(x,y=NULL,z=NULL,texts,pmat,...) } \arguments{ \item{x,y,z}{ x, y and z coordinates to plot. \samp{x} may be a list with three components.} \item{pmat}{ matrix to transform coordinates. } \item{texts}{ text to display. } \item{...}{ Other arguments passed to \samp{segments}. } } \details{ Draws text on a perspective plot. } \value{nil} \author{Ben Bolker} \keyword{misc} plotrix/man/psegments3d.Rd0000755000176000001440000000101011441423200015263 0ustar ripleyusers\name{psegments3d} \alias{psegments3d} \title{ Draw segments on a 3D plot } \description{ Draw segments on a 3D plot defined by a list of coordinates } \usage{ psegments3d(x,y=NULL,z=NULL,pmat,...) } \arguments{ \item{x,y,z}{ x, y and z coordinates to plot. \samp{x} may be a list with three components.} \item{pmat}{ matrix to transform coordinates. } \item{...}{ Other arguments passed to \samp{segments}. } } \details{ Draws segments on a perspective plot. } \value{nil} \author{Ben Bolker} \keyword{misc} plotrix/man/propbrk.Rd0000644000176000001440000000142612022365754014535 0ustar ripleyusers\name{propbrk} \alias{propbrk} \title{Calculate the proportion of specified values in a vector} \description{ Calculates the proportion of values in a vector that are equal to a specified value. } \usage{ propbrk(x,trueval=TRUE,na.rm=TRUE) } \arguments{ \item{x}{a character, factor or numeric vector.} \item{trueval}{the value to be matched in \samp{x}.} \item{na.rm}{whether to remove NA values.} } \details{ \samp{propbrk} calculates the proportion of values matching a specified value. It is mainly to allow proportions to be calculated in the \samp{brkdnNest} function. It now discards NA values in \samp{x} when calculating proportions. } \value{nil} \author{Jim Lemon} \seealso{\link{brkdnNest}} \examples{ propbrk(sample(LETTERS,100,TRUE),trueval="M") } \keyword{misc} plotrix/man/print.brklist.Rd0000755000176000001440000000144111463773730015670 0ustar ripleyusers\name{print.brklist} \alias{print.brklist} \title{Display the output of brkdnNest} \description{ Displays the list of values produced by \samp{brkdnNest}. } \usage{ \method{print}{brklist}(x,...) } \arguments{ \item{x}{a list of summary values produced by \samp{\link{brkdnNest}}} \item{...}{additional arguments passed to \samp{print}.} } \details{ \samp{print.brklist} displays frequency tables produced by \samp{brkdnNest}. It is mainly for convenience, but does make a nicer display than when passed directly to \samp{print} } \value{nil} \author{Jim Lemon} \seealso{\link{brkdnNest}} \examples{ printbrktest<-data.frame(A=c(sample(1:10,99,TRUE),NA), B=sample(c("Yes","No"),100,TRUE), C=sample(LETTERS[1:3],100,TRUE)) pbt<-brkdnNest(A~B+C,printbrktest) print(pbt) } \keyword{misc} plotrix/man/polygon.shadow.Rd0000755000176000001440000000454612073517232016036 0ustar ripleyusers\name{polygon.shadow} \alias{polygon.shadow} \title{Display a shadow effect for an arbitrary polygon} \description{ Displays a shadow effect on an existing plot } \usage{ polygon.shadow(x,y=NULL,offset=NA,inflate=NA,col=c("#ffffff","#cccccc")) } \arguments{ \item{x,y}{x and y coordinate of the vertices of the polygon. \samp{y} can be missing if \samp{x} is a list with \samp{x} and \samp{y} components.} \item{offset}{a vector containing the values of the x and y offsets for the shadow. Defaults to 1/20 of the maximum x and y dimensions of the polygon.} \item{col}{the colors of the shadow from the outer edge to the central part.} \item{inflate}{the amount to "inflate" the shadow relative to the polygon (i.e. the penumbra). Defaults to the values in \samp{offset}.} } \value{nil} \details{ \samp{polygon.shadow} is typically called just before drawing a polygon. It displays a shadow effect by drawing the polygon ten times, beginning with the first color in \samp{col} and stepping through to the second color to create a "shadow" (or a "halo" if you prefer). Each successive polygon is shrunk by 10\% of \samp{inflate}. The default shadow effect has the light at the upper left. This effect may also be used as a text background. } \note{ The background must be a constant color or the shadow effect will not look right. A good starting point for the two colors is the color of the background and the RGB components of that color multiplied by 0.8. Use a smaller multiplier for a darker shadow. } \author{Jim Lemon} \seealso{\link{polygon}} \examples{ par(pty="s") plot(1:5,type="n",main="Polygon Shadow test",xlab="",ylab="",axes=FALSE) box() # do a shadow on a yellow square polygon(c(1,2.2,2.2,1),c(5,5,3.8,3.8),col="#ffff00") polygon.shadow(c(1.2,2,2,1.2),c(4.8,4.8,4,4),col=c("#ffff00","#cccc00")) polygon(c(1.2,2,2,1.2),c(4.8,4.8,4,4),col=c("#ff0000")) # a green triangle on a light blue square with a big offset polygon(c(4,5,5,4),c(2,2,1,1),col="#aaaaff") polygon.shadow(c(4.5,4.8,4.2),c(1.7,1.2,1.2),col=c("#aaaaff","#8888cc"), offset=c(0.1,-0.1),inflate=c(0.2,0.2)) polygon(c(4.5,4.8,4.2),c(1.7,1.2,1.2),col=c("#00ff00")) # now a circle as a background polygon.shadow(cos(seq(0,2*pi,by=pi/20))+3,sin(seq(0,2*pi,by=pi/20))+3, offset=c(0,0),inflate=c(0.1,0.1)) text(3,3,"Polygon shadow\nas a circular\ntext background",cex=1.5) } \keyword{misc} plotrix/man/polar.plot.Rd0000755000176000001440000000377311614225752015161 0ustar ripleyusers\name{polar.plot} \title{Plot values on a circular grid of 0 to 360 degrees} \usage{ polar.plot(lengths,polar.pos=NULL,labels,label.pos=NULL, start=0,clockwise=FALSE,rp.type="r",...) } \alias{polar.plot} \arguments{ \item{lengths}{numeric data vector. Magnitudes will be represented as the radial positions of symbols, line ends or polygon vertices.} \item{polar.pos}{numeric vector of positions on a 0:360 degree circle. These will be converted to radians when passed to \samp{radial.plot}.} \item{labels}{text labels to place on the periphery of the circle. This defaults to labels every 20 degrees. For no labels, pass an empty string.} \item{label.pos}{positions of the peripheral labels in degrees} \item{start}{The position for zero degrees on the plot in degrees.} \item{clockwise}{Whether to increase angles clockwise rather than the default counterclockwise.} \item{rp.type}{Whether to plot radial lines, symbols or a polygon.} \item{...}{additional arguments passed to \samp{radial.plot} and then to \samp{plot}.} } \description{ \samp{polar.plot} displays a plot of radial lines, symbols or a polygon centered at the midpoint of the plot frame on a 0:360 circle. Positions are interpreted as beginning at the right and moving counterclockwise unless \samp{start} specifies another starting point or \samp{clockwise} is TRUE. If \samp{add=TRUE} is passed as one of the additional arguments, the values will be added to the current plot. If a \samp{radial.lim} argument was passed on the initial plot, it must be passed again to add values or the values will be displayed incorrectly. } \value{A list of the parameters altered by \link{radial.plot}.} \author{Jim Lemon} \keyword{misc} \seealso{\link{radial.plot}} \examples{ testlen<-c(rnorm(36)*2+5) testpos<-seq(0,350,by=10) polar.plot(testlen,testpos,main="Test Polar Plot",lwd=3,line.col=4) oldpar<-polar.plot(testlen,testpos,main="Test Clockwise Polar Plot", start=90,clockwise=TRUE,lwd=3,line.col=4) # reset everything par(oldpar) } plotrix/man/plotCI.Rd0000755000176000001440000000645411476253170014261 0ustar ripleyusers\name{plotCI} \alias{plotCI} \title{Plot confidence intervals/error bars} \description{ Given a set of x and y values and upper and lower bounds, this function plots the points with error bars. } \usage{ plotCI(x,y=NULL,uiw,liw=uiw,ui=NULL,li=NULL,err="y", sfrac=0.01,gap=0,slty=par("lty"),add=FALSE,scol=NULL,pt.bg=par("bg"),...) } \arguments{ \item{x}{The x coordinates of points in the plot} \item{y}{The y coordinates of points in the plot} \item{uiw}{The width of the upper portion of the confidence region, or (if \samp{liw} is missing) the width of both halves of the confidence region} \item{liw}{The width of the lower portion of the confidence region (if missing, the function assumes symmetric confidence bounds)} \item{ui}{The absolute upper limit of the confidence region} \item{li}{The absolute lower limit of the confidence region} \item{err}{The direction of error bars: "x" for horizontal, "y" for vertical ("xy" would be nice but is not implemented yet; don't know quite how everything would be specified. See examples for composing a plot with simultaneous horizontal and vertical error bars)} \item{gap}{Size of gap in error bars around points (default 0;gap=TRUE gives gap size of 0.01)} \item{sfrac}{Scaling factor for the size of the "serifs" (end bars) on the confidence bars, in x-axis units} \item{add}{If FALSE (default), create a new plot; if TRUE, add error bars to an existing plot.} \item{slty}{Line type of error bars} \item{scol}{Color of error bars: if \samp{col} is specified in the optional arguments, \samp{scol} is set the same; otherwise it's set to \samp{par(col)}} \item{pt.bg}{Background color of points (use pch=21, pt.bg=par("bg") to get open points superimposed on error bars)} \item{\dots}{Any other parameters to be passed through to \link{plot.default}, \link{points}, \link{arrows}, etc. (e.g. \samp{lwd}, \samp{col}, \samp{pch}, \samp{axes}, \samp{xlim}, \samp{ylim}). \samp{xlim} and \samp{ylim} are set by default to include all of the data points and error bars. \samp{xlab} and \samp{ylab} are set to the names of \samp{x} and \samp{y}. If \samp{pch==NA}, no points are drawn (e.g. leaving room for text labels instead)} } \value{ invisible(x,y); creates a plot on the current device. } \author{Ben Bolker (documentation and tweaking of a function provided by Bill Venables, additional feature ideas from Gregory Warnes)} \seealso{\link{boxplot}} \examples{ y<-runif(10) err<-runif(10) plotCI(1:10,y,err,main="Basic plotCI") plotCI(1:10,y,err,2*err,lwd=2,col="red",scol="blue", main="Add colors to the points and error bars") err.x<-runif(10) err.y<-runif(10) plotCI(1:10,y,err.y,pt.bg=par("bg"),pch=21,xlim=c(0,11), main="plotCI with extra space on the x axis") plotCI(1:10,y,err.x,pt.bg=par("bg"),pch=21,err="x",add=TRUE) mtext("for adding horizontal error bars",3,0.5) data(warpbreaks) attach(warpbreaks) wmeans<-by(breaks,tension,mean) wsd<-by(breaks,tension,sd) ## note that barplot() returns the midpoints of the bars, which plotCI ## uses as x-coordinates plotCI(barplot(wmeans,col="gray",ylim=c(0,max(wmeans+wsd))),wmeans,wsd,add=TRUE) ## using labels instead of points labs<-sample(LETTERS,replace=TRUE,size=10) plotCI(1:10,y,err,pch=NA,gap=0.02,main="plotCI with labels at points") text(1:10,y,labs) } \keyword{hplot} plotrix/man/plot.dendrite.Rd0000755000176000001440000000226211512555051015625 0ustar ripleyusers\name{plot.dendrite} \alias{plot.dendrite} \title{Plot a dendrogram of a dendrite object} \description{Plot a dendrogram for two or more mutually exclusive attributes.} \usage{ \method{plot}{dendrite}(x,xlabels=NULL,main="",mar=c(1,0,3,0),cex=1,...) } \arguments{ \item{x}{A \samp{dendrite} object containing the counts of objects having combinations of mutually exclusive attributes.} \item{xlabels}{The category labels that will be displayed beneath the dendrogram.} \item{main}{The title of the plot.} \item{mar}{Margins for the plot.} \item{cex}{Character expansion for the leaves of the dendrogram.} \item{...}{Additional arguments passed to \samp{plot}.} } \details{ \samp{plot.dendrite} sets up a plot for a dendrogram. The actual plotting of the dendrogram is done by \samp{furc}. } \value{nil} \author{Jim Lemon} \seealso{\link{furc}} \examples{ sex<-sample(c("M","F"),100,TRUE) hair<-c(sample(c("Blond","Black","Brown","Red"),90,TRUE),rep(NA,10)) eye<-sample(c("Blue","Black","Brown","Green"),100,TRUE) charac<-data.frame(sex=sex,hair=hair,eye=eye) characlist<-makeDendrite(charac) plot.dendrite(characlist,names(charac),main="Test dendrogram",cex=0.8) } \keyword{misc} plotrix/man/pie3D.labels.Rd0000755000176000001440000000323211745756536015300 0ustar ripleyusers\name{pie3D.labels} \alias{pie3D.labels} \title{Display labels on a 3D pie chart} \description{ Displays labels on a 3D pie chart. } \usage{ pie3D.labels(radialpos,radius=1,height=0.1,theta=pi/6, labels,labelcol=par("fg"),labelcex=1.5,labelrad=1.25,minsep=0.3) } \arguments{ \item{radialpos}{Position of the label in radians} \item{radius}{the radius of the pie in user units} \item{height}{the height of the pie in user units} \item{theta}{The angle of viewing in radians} \item{labels}{The label to display} \item{labelcol}{The color of the labels} \item{labelcex}{The character expansion factor for the labels} \item{labelrad}{The expansion for the labels around the pie.} \item{minsep}{The minimum angular separation between label positions.} } \value{ nil } \details{ \samp{pie3D.label} displays labels on a 3D pie chart. The positions of the labels are given as angles in radians (usually the bisector of the pie sectors). As the labels can be passed directly to \link{pie3D}, this function would probably not be called by the user. \samp{pie3D.labels} tries to separate labels that are placed closer than \samp{minsep} radians. This simple system will handle minor crowding of labels. If labels are very crowded, capturing the return value of \samp{pie3D} and editing the label positions may allow the user to avoid manually placing labels. } \author{Jim Lemon} \seealso{\link{pie3D}, \link{draw.tilted.sector}} \examples{ pieval<-c(2,4,6,8) bisectors<-pie3D(pieval,explode=0.1,main="3D PIE OPINIONS") pielabels<- c("We hate\n pies","We oppose\n pies","We don't\n care","We just love pies") pie3D.labels(bisectors,labels=pielabels) } \keyword{misc} plotrix/man/pie3D.Rd0000755000176000001440000000770611745757557014055 0ustar ripleyusers\name{pie3D} \alias{pie3D} \title{Display a 3D pie chart} \description{ Displays a 3D pie chart with optional labels. } \usage{ pie3D(x,edges=NA,radius=1,height=0.1,theta=pi/6,start=0,border=par("fg"), col=NULL,labels=NULL,labelpos=NULL,labelcol=par("fg"),labelcex=1.5, sector.order=NULL,explode=0,shade=0.8,mar=c(4,4,4,4),pty="s",...) } \arguments{ \item{x}{a numeric vector for which each value will be a sector} \item{edges}{the number of lines forming an ellipse} \item{radius}{the radius of the pie in user units} \item{height}{the height of the pie in user units} \item{theta}{The angle of viewing in radians} \item{start}{The angle at which to start drawing sectors.} \item{border}{The color of the sector border lines} \item{col}{The colors of the sectors} \item{labels}{Optional labels for each sector} \item{labelpos}{Optional positions for the labels (see examples)} \item{labelcol}{The color of the labels} \item{labelcex}{The character expansion factor for the labels} \item{sector.order}{Allows the operator to specify the order in which the sectors are drawn.} \item{explode}{The amount to "explode" the pie in user units} \item{shade}{If > 0 and < 1, the proportion to reduce the brightness of the sector color to get a better 3D effect.} \item{mar}{Margins around the pie.} \item{pty}{Whether to force a square plot region or not. (see Details)} \item{...}{graphical parameters passed to \samp{plot}} } \value{ The bisecting angle of the sectors in radians. } \details{ \samp{pie3D} scales the values in \samp{x} so that they total 2*pi, dropping zeros and NAs. It then displays an empty plot, calculates the sequence for drawing the sectors and calls \samp{draw.tilted.sector} to draw each sector. If labels are supplied, it will call \samp{pie3D.label} to place these outside each sector. If supplied, the number of labels, label positions and sector colors must be at least equal to the number of values in \samp{x}. If the labels are long, it may help to reduce the radius of the pie or change the position as in the example below. In order to make the dimensions of the pie reasonably accurate, a square plot region (\samp{pty="s"}) is the default. If \samp{pty} is set to "m", the user can change the margins, usually resulting in a non-square plot area. This will probably distort the pie somewhat. } \note{ Due to the somewhat primitive method used to draw sectors, a sector that extends beyond both pi/2 and 3*pi/2 radians in either direction may not display properly. Setting \samp{start} to pi/2 will often fix this, but the user may have to adjust \samp{start} and the order of sectors in extreme cases. The argument \samp{sector.order} allows the user to specify a vector of integers that will override the calculation of the order in which the sectors are drawn. This is usually necessary when a very large sector that extends past 3*pi/2 is overlapped by a smaller sector next to it. As a last resort, the user can try setting \samp{explode} to zero. This only draws the top and outer sides of each sector. Also due to the sector drawing method, setting \samp{theta} to values smaller than about pi/8 or larger than about pi/4 will produce obviously misaligned sectors. Contributed fixes and improvements: thanks to Jesse Brown for the "shade" fix and Qinghua Zhao for alerting me to the problem with labels and margins } \author{Jim Lemon} \seealso{\link{pie3D.labels}, \link{draw.tilted.sector}} \examples{ pieval<-c(2,4,6,8) pielabels<- c("We hate\n pies","We oppose\n pies","We don't\n care","We just love pies") # grab the radial positions of the labels lp<-pie3D(pieval,radius=0.9,labels=pielabels,explode=0.1,main="3D PIE OPINIONS") # lengthen the last label and move it to the left pielabels[4]<-"We cannot survive without our pies" lp[4]<-4.8 # specify some new colors pie3D(pieval,radius=0.9,labels=pielabels,explode=0.1,main="3D PIE OPINIONS", col=c("brown","#ddaa00","pink","#dd00dd"),labelpos=lp) } \keyword{misc} plotrix/man/pie.labels.Rd0000755000176000001440000000313212132125255015063 0ustar ripleyusers\name{pie.labels} \alias{pie.labels} \title{ Place labels on a pie chart } \description{ Places labels on a pie chart } \usage{ pie.labels(x,y,angles,labels,radius=1,bg="white",border=TRUE,minangle=NA,...) } \arguments{ \item{x,y}{x and y position of the center of the pie chart} \item{angles}{A numeric vector representing angles in radians. This is the return value of \samp{floating.pie}.} \item{labels}{Text strings to label each sector.} \item{radius}{The radius at which to place the labels in user units. The default is 1.} \item{bg}{The color of the rectangles on which the labels are displayed.} \item{border}{Whether to draw borders around the rectangles.} \item{minangle}{Minimum angle between labels.} \item{...}{Arguments passed to \samp{boxed.labels}.} } \value{nil} \details{ Labels may be placed within the pie (radius less than the pie radius), on the edge or outside as in the examples below. If some labels overlap, passing a value in radians for \samp{minangle} may be used to spread them out. } \note{ Remember that \samp{x} and \samp{y} specify the center of the pie chart and that the label positions are specified by angles and radii from that center. } \author{Jim Lemon} \seealso{\link{floating.pie}, \link{boxed.labels}, \link{spreadout}} \examples{ pieval<-c(2,1,3,94) plot(1:5,type="n",axes=FALSE,xlab="",ylab="") box() bisect.angles<-floating.pie(3,3,pieval) pie.labels(3,3,bisect.angles,c("two","one","three","ninety\nfour")) pie.labels(3,3,bisect.angles,radius=1.5, c("First\nvalue","Second\nvalue","Third\nvalue","Fourth\nvalue"), minangle=0.2) } \keyword{misc} plotrix/man/perspx.Rd0000755000176000001440000000127611441420720014372 0ustar ripleyusers\name{perspx} \alias{perspx} \title{ Display perspective plot } \description{ Display an enhanced perspective plot with additional return values } \usage{ perspx(x,y,z,...) } \arguments{ \item{x,y,z}{ x, y and z coordinates to plot. } \item{...}{ Other arguments passed to \samp{persp}. } } \details{ Displays \samp{z} values plotted on an x,y grid. } \value{ A list with three elements, the ranges of \samp{x}, \samp{y} and \samp{z}. } \author{Ben Bolker} \examples{ x <- 1:10 y <- 1:10 z <- outer(x,y,function(x,y) { 3*sin(2*pi*x)/(2*pi*x)+exp(y/10)+(x*y)/1000 }) par(mar=c(5,10,2,2)) pp <- perspx(x,y,z,ticktype="detailed",phi=30,theta=80,nticks=3,r=10, axes=FALSE) } \keyword{misc} plotrix/man/paxis3d.Rd0000755000176000001440000000270611441657750014442 0ustar ripleyusers\name{paxis3d} \alias{paxis3d} \title{ Display text in the margins of a 3D plot } \description{ Display text in the margins of a 3D plot. } \usage{ paxis3d(edge,pmat,at=NULL,labels=TRUE,tick=TRUE, pos=NULL,nticks=5,ticklen=0.05,labdist=0.15,xpd=NA,...) } \arguments{ \item{edge}{ which axis to calculate.} \item{pmat}{ matrix to transform coordinates. } \item{at}{ position on the axis. } \item{labels}{ labels to display in the margin. } \item{tick}{ whether to draw axis tick marks. } \item{pos}{ axis position relative to other axes. } \item{nticks}{ number of tick marks. } \item{ticklen}{ length of tick marks as a proportion of plot dimensions. } \item{labdist}{ distance of labels from axis. } \item{xpd}{ parameter to set plot clipping. } \item{...}{ additional arguments passed to ptext3d. } } \value{nil} \author{Ben Bolker} \examples{ x <- 1:10 y <- 1:10 z <- outer(x,y,function(x,y) { 3*sin(2*pi*x)/(2*pi*x)+exp(y/10)+(x*y)/1000 }) par(mar=c(5,10,2,2)) pp <- perspx(x,y,z,ticktype="detailed",phi=30,theta=80,nticks=3,r=10, axes=FALSE) ## axis labels not drawn when axes=FALSE paxis3d("X-",pp,at=c(1,2,9)) paxis3d("Y+",pp) paxis3d("Z-",pp) mtext3d("X-",pp,expression(alpha^sqrt(beta))) ## if you want labels parallel to axis, still have to figure out 'srt' ## by trial and error mtext3d("Y+",pp,expression("velocity ("*gamma*", furlongs/fortnight)"), xpd=NA,srt=6) mtext3d("Z-",pp,"Range\n(r*)",dist=0.5) } \keyword{misc} plotrix/man/pasteCols.Rd0000755000176000001440000000157211334502152015006 0ustar ripleyusers\name{pasteCols} \alias{pasteCols} \title{Paste the columns of a matrix together} \description{Paste the columns of a matrix together to form as many "words" as there are columns.} \usage{ pasteCols(x,sep="") } \arguments{ \item{x}{A matrix.} \item{sep}{The separator to use in the \samp{paste} command.} } \details{ \samp{pasteCols} pastes the columns of a matrix together to form a vector in which each element is the concatenation of the elements in each of the columns of the matrix. It is intended for producing identifiers from a matrix returned by the \samp{combn} function. } \value{A vector of character strings.} \keyword{misc} \author{Jim Lemon} \seealso{\link{makeIntersectList}} \examples{ # create a matrix of the combinations of the first five letters of the # alphabet taken two at a time. alpha5<-combn(LETTERS[1:5],2,simplify=TRUE) pasteCols(alpha5,sep="+") } plotrix/man/panes.Rd0000755000176000001440000000560011422023546014156 0ustar ripleyusers\name{panes} \alias{panes} \title{Prepare a "panel" type layout} \description{ Split the graphics device into a "panel" type layout for a group of plots } \usage{ panes(mat=NULL,widths=rep(1,ncol(mat)),heights=rep(1,nrow(mat)), nrow=2,ncol=2,mar=c(0,0,1.6,0),oma=c(2.5,1,1,1)) } \arguments{ \item{mat}{A matrix representing the number of panes to be created and their order of plotting.} \item{widths,heights}{The widths and heights of the panes. See \samp{layout}.} \item{nrow,ncol}{The numbers of rows and columns in the layout. See \samp{par(mfrow)}.} \item{mar}{The margins for each plot in the panes.} \item{oma}{The outer margins for the entire group of panes.} } \details{ \samp{panes} combines the information for displaying a set of plots in a "panel" layout. The default values will usually produce the desired result by calling \samp{par(mfrow)}. If \samp{mat} is not NULL, the \samp{layout} function will be called instead of \samp{par(mfrow)}. The two methods are included for the convenience of the user. Note that \samp{panes} does not produce any plots and that the user must call \samp{tab.title} to get the "look" of the panel plot. The overall title is usually centered at the left edge (as in the example) or in the center of one of the plots in the bottom row. } \value{ The values of \samp{par} options that existed when \samp{panes} was called. This list is usually used to restore those values. } \author{Jim Lemon} \seealso{\link{par},\link{layout}} \examples{ y<-runif(8) oldpar<-panes(matrix(1:4,nrow=2,byrow=TRUE)) par(mar=c(0,2,1.6,0)) boxplot(y,axes=FALSE) axis(2) box() par(mar=c(0,0,1.6,2)) tab.title("Boxplot of y",tab.col="#88dd88") barplot(y,axes=FALSE,col=2:9) axis(4) box() tab.title("Barplot of y",tab.col="#88dd88") par(mar=c(2,2,1.6,0)) pie(y,col=2:9) tab.title("Pie chart of y",tab.col="#88dd88") box() par(mar=c(2,0,1.6,2)) plot(y,xaxs="i",xlim=c(0,9),axes=FALSE,col=2:9) axis(4) box() tab.title("Scatterplot of y",tab.col="#88dd88") # center the title at the left edge of the last plot mtext("Test of panes function",at=0,side=1,line=0.8,cex=1.5) panes(matrix(1:3,ncol=1),heights=c(0.7,0.8,1)) par(mar=c(0,2,2,2)) plot(sort(runif(7)),type="l",axes=FALSE) axis(2,at=seq(0.1,0.9,by=0.2)) box() tab.title("Rising expectations",tab.col="#ee6666") barplot(rev(sort(runif(7))),col="blue",axes=FALSE) axis(2,at=seq(0.1,0.9,by=0.2)) box() tab.title("Diminishing returns",tab.col="#6666ee") par(mar=c(4,2,2,2)) tso<-c(0.2,0.3,0.5,0.4,0.6,0.8,0.1) plot(tso,type="n",axes=FALSE,xlab="") # the following needs a Unicode locale to work points(1:7,tso,pch=c(rep(-0x263a,6),-0x2639),cex=2) axis(1,at=1:7, labels=c("Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","Monday")) axis(2,at=seq(0.1,0.9,by=0.2)) box() tab.title("The sad outcome",tab.col="#66ee66") mtext("A lot of malarkey",side=1,line=2.5) par(oldpar) } \keyword{misc} plotrix/man/oz.windrose.legend.Rd0000755000176000001440000000177611470461232016601 0ustar ripleyusers\name{oz.windrose.legend} \alias{oz.windrose.legend} \title{Display an Australian wind rose legend} \description{ Displays a wind rose legend in the style used by the Australian Bureau of Meteorology. } \usage{ oz.windrose.legend(maxpct=20,scale.factor=30, speed.col=c("#dab286","#fe9a66","#ce6733","#986434"), speed.width=NA,legend.pos=NA) } \arguments{ \item{maxpct}{The maximum percentage to display on the radial grid.} \item{scale.factor}{The scale factor for the plot.} \item{speed.col}{Colors representing speed ranges.} \item{speed.width}{Half widths of the bars representing speed ranges.} \item{legend.pos}{The vertical position of the wind rose legend. The Australian Bureau of Meteorology displays the legend at the top of the plot} } \value{nil} \author{Jim Lemon (thanks to Anna in the Sydney BoM office)} \seealso{\link{oz.windrose}} \examples{ plot(0,xlim=c(-20,20),ylim=c(-20,20),type="n",axes=FALSE,xlab="",ylab="") par(xpd=TRUE) oz.windrose.legend() par(xpd=FALSE) } \keyword{misc} plotrix/man/oz.windrose.Rd0000755000176000001440000000436511470461652015347 0ustar ripleyusers\name{oz.windrose} \alias{oz.windrose} \title{Display an Australian wind rose} \description{Displays a wind rose in the style used by the Australian Bureau of Meteorology.} \usage{ oz.windrose(windagg,maxpct=20,wrmar=c(4,5,6,5),scale.factor=30, speed.col=c("#dab286","#fe9a66","#ce6733","#986434"), speed.width=NA,show.legend=TRUE,legend.pos=NA,...) } \arguments{ \item{windagg}{A matrix of percentages with the rows representing speed ranges and the columns indicating wind directions.} \item{maxpct}{The maximum percentage displayed on the radial grid.} \item{wrmar}{Plot margins for the diagram.} \item{scale.factor}{The scale factor for the diagram.} \item{speed.col}{Colors representing speed ranges.} \item{speed.width}{Half widths of the bars representing speed ranges.} \item{show.legend}{Logical indicating whether to display a legend.} \item{legend.pos}{The vertical position of the wind rose legend. The Australian Bureau of Meteorology displays the legend at the top of the plot} \item{...}{additional arguments passed to \samp{plot}.} } \details{ \samp{oz.windrose} displays a wind rose in the style used by the Australian Bureau of Meteorology. Each limb represents a bin of wind directions, and there are conventionally eight bins. If \samp{windagg} has more than eight columns, more limbs will be displayed. The rows of \samp{windagg} represent the speed ranges used by the Australian Bureau of Meteorology (0, 0-10, 10-20, 20-30 and over 30 in km/hour). The diameter of the central circle is calculated as (percent calm observations)/(number of direction bins). The remaining grid circles are spaced from the circumference of the "Calm" circle. } \note{ If a title is desired, remember to move the legend to the bottom of the plot. If the function is passed values that do not sum to 100, the resulting plot will at best be misleading. } \value{nil} \author{Jim Lemon (thanks to Anna in the Sydney BoM office and Alejo for finding the problem with heavily prevailing winds.)} \seealso{\link{oz.windrose.legend}, \link{draw.circle}, \link{bin.wind.records}} \examples{ windagg<-matrix(c(8,0,0,0,0,0,0,0,4,6,2,1,6,3,0,4,2,8,5,3,5,2,1,1, 5,5,2,4,1,4,1,2,1,2,4,0,3,1,3,1),nrow=5,byrow=TRUE) oz.windrose(windagg) } \keyword{misc} plotrix/man/multsymbolbox.Rd0000755000176000001440000000171311056465626016005 0ustar ripleyusers\name{multsymbolbox} \alias{multsymbolbox} \title{Draw boxes filled with symbols} \description{ Draw boxes on the current figure filled with symbols representing individual counts. } \usage{ multsymbolbox(x1,y1,x2,y2,tot,relw=0.8,fg=par("fg"),bg=par("bg"), box=TRUE,debug=FALSE,...) } \arguments{ \item{x1}{numeric vector: left sides of boxes} \item{y1}{numeric vector: bottom sides of boxes} \item{x2}{numeric vector: right sides of boxes} \item{y2}{numeric vector: top sides of boxes} \item{tot}{numeric vector: total numbers of symbols to put in each box} \item{relw}{relative width (relative to height) of symbols}n \item{fg}{foreground color(s)} \item{bg}{background color(s)} \item{box}{(logical) draw box borders?} \item{debug}{debug output?} \item{\dots}{additional arguments to polygon() for drawing boxes} } \value{ none } \author{Ben Bolker} \examples{ plot(1:10,1:10,type="n") multsymbolbox(c(2,4),5,c(4,5),8,tot=c(10,8)) } \keyword{aplot} plotrix/man/multhist.Rd0000755000176000001440000000275111721661775014743 0ustar ripleyusers\name{multhist} \alias{multhist} \title{Plot a multiple histogram, as a barplot} \description{ Given a list, plots a side-by-side barplot containing the histograms of the elements } \usage{ multhist(x,beside=TRUE,freq=NULL,probability=!freq,plot.it=TRUE,...) } \arguments{ \item{x}{a list of numeric vectors} \item{beside}{plot histogram bars for groups side-by-side?} \item{freq}{logical; if 'TRUE', the histogram graphic is a representation of frequencies, the 'counts' component of the result; if 'FALSE', probability densities, component 'density', are plotted (so that the histogram has a total area of one). Defaults to 'TRUE' if 'probability' is not specified (does not consider equidistant breaks as in \link{hist})} \item{probability}{an alias for '!freq', for S compatibility} \item{plot.it}{Whether or not to display the histogram.} \item{...}{additional arguments to \link{hist} or \link{barplot}} } \value{ A list including the return value for the first call to \samp{hist} (itself a list) and the values for the bar heights. } \author{Ben Bolker} \seealso{\link{hist},\link{barplot}} \note{ The 'inside' argument to \link{barplot} (which is not currently implemented in barplot anyway) is deleted from the argument list. The default value of NULL for \samp{freq} is for consistency with \samp{hist} but is equivalent to TRUE. } \examples{ l <- list(runif(10)*10,1:10,c(1,1,1,1,4,8)) multhist(l) } \keyword{hplot} plotrix/man/mtext3d.Rd0000755000176000001440000000110411441657646014452 0ustar ripleyusers\name{mtext3d} \alias{mtext3d} \title{ Display text in the margins of a 3D plot } \description{ Display text in the margins of a 3D plot. } \usage{ mtext3d(edge,pmat,labels=TRUE,at=NULL,dist=0.3,xpd=NA,...) } \arguments{ \item{edge}{ which axis to calculate.} \item{pmat}{ matrix to transform coordinates. } \item{labels}{ labels to display in the margin. } \item{at}{ position on the axis. } \item{dist}{ Offset of the axis. } \item{xpd}{ set clipping for display. } \item{...}{ additional arguments passed to ptext3d. } } \value{nil} \author{Ben Bolker} \keyword{misc} plotrix/man/maxEmptyRect.Rd0000644000176000001440000000274311672577446015520 0ustar ripleyusers\name{maxEmptyRect} \alias{maxEmptyRect} \title{ Find an empty space on a plot } \description{ Try to find the largest empty rectangle on a plot. } \usage{ maxEmptyRect(ax,ay,x,y) } \arguments{ \item{ax,ay}{The rectangle within which all of the points are contained. Usually the limits of a plot.} \item{x,y}{x and y positions of the points.} } \details{ \samp{maxEmptyRect} searches the pairs of points on the plot to find the largest rectangular space within which none of the points lie. It does not guarantee that the space will be large enough to fit a legend or text. Two alternatives are the \samp{largest.empty} function in the \pkg{Hmisc} package and the \samp{emptyspace} function. \samp{maxEmptyRect} appears to outperform \samp{emptyspace}, particularly in running time. However, \samp{emptyspace} will sometimes find a "squarer" rectangle when \samp{maxEmptyRect} finds a slightly larger narrow rectangle. } \value{ A list containing the area of the rectangle and the coordinates of the lower left and upper right corners (as used in \samp{rect}) of the rectangle found. } \author{Hans Borchers} \references{ A. Naamad, D. T. Lee, and W.-L. Hsu (1984). On the Maximum Empty Rectangle Problem. Discrete Applied Mathematics, 8: 267-277. } \examples{ x<-runif(100) y<-runif(100) plot(x,y,main="Find the maximum empty rectangle",xlab="X",ylab="Y") mer<-maxEmptyRect(c(0,1),c(0,1),x,y) rect(mer$rect[1],mer$rect[2],mer$rect[3],mer$rect[4],border="red") } \keyword{misc} plotrix/man/makeIntersectList.Rd0000755000176000001440000000546511571143534016520 0ustar ripleyusers\name{makeIntersectList} \alias{makeIntersectList} \title{Count set intersections} \description{Create a list of set intersections from a matrix of indicators} \usage{ makeIntersectList(x,xnames=NULL,sep="+") } \arguments{ \item{x}{A data frame or matrix where rows represent objects and columns attributes. A \samp{1} or \samp{TRUE} indicates that the object (row) has that attribute or is a member of that set (column). \samp{x} can also be a matrix or data frame in which the first column contains object identifiers and the second contains attribute codes.} \item{xnames}{Optional user-supplied names for the attributes of x.} \item{sep}{A character to use as a separator for attribute labels.} } \details{ \samp{makeIntersectList} reads a matrix (or data frame where all values are the same type) containing dichotomous values (either 0/1 or FALSE/TRUE) or labels (see next paragraph). In the first type of input, each row represents an object and each column represents a set. A value of 1 or TRUE indicates that that object is a member of that set. The function creates a list of vectors that correspond to all combinations of the sets (set intersections) and inserts the counts of elements in each combination. If a row of \samp{x} is all zeros, it will not be counted, but the second last element of the list returned contains the count of rows in \samp{x} and thus non-members can be calculated. If a matrix (or data frame where all values are the same type) containing values other than 0/1 or TRUE/FALSE, it will be passed to \samp{categoryReshape} for conversion to a data frame as described above. See \samp{categoryReshape} for details of this. makeIntersectList combines the set or attribute names to form intersection names. For the intersection of sets A and B, the name will be A+B (unless \samp{sep} is changed) and so on. These are the names that will be displayed by \samp{intersectDiagram}. To change these, use the \samp{xnames} argument. } \value{ A list of the intersection counts or percentages, the total number of objects and the attribute codes. } \keyword{misc} \author{Jim Lemon} \seealso{\link{intersectDiagram}, \link{pasteCols}, link{categoryReshape}} \examples{ # create a matrix where each row represents an element and # a 1 (or TRUE) in each column indicates that the element is a member # of that set. setdf<-data.frame(A=sample(c(0,1),100,TRUE,prob=c(0.7,0.3)), B=sample(c(0,1),100,TRUE,prob=c(0.7,0.3)), C=sample(c(0,1),100,TRUE,prob=c(0.7,0.3)), D=sample(c(0,1),100,TRUE,prob=c(0.7,0.3))) makeIntersectList(setdf) ns<-sample(1:8,20,TRUE) objects<-0 for(i in 1:length(ns)) objects<-c(objects,rep(i,ns[i])) attributes<-"Z" for(i in 1:length(ns)) attributes<-c(attributes,sample(LETTERS[1:8],ns[i])) setdf2<-data.frame(objects[-1],attributes[-1]) makeIntersectList(setdf2) } plotrix/man/makeDendrite.Rd0000755000176000001440000000231011334502074015437 0ustar ripleyusers\name{makeDendrite} \alias{makeDendrite} \title{Build a list of the mutually exclusive attributes of objects} \description{Build a list of mutually exclusive attributes from a matrix of category indicators.} \usage{ makeDendrite(x) } \arguments{ \item{x}{A data frame or matrix where rows represent objects and columns mutually exclusive attributes of a given class.} } \details{ The values in \samp{x} indicate which attribute of a particular class is possessed by the object. For instance, the attributes dead and alive are mutually exclusive. \samp{makeDendrite} creates a nested list that contains the counts of successive combinations of the attributes. The top level attributes are taken from the first column, then those are combined with the attributes in the second column and so on. } \value{ A list of the counts of objects for each combination of the attribute classes. } \keyword{misc} \author{Jim Lemon} \seealso{\link{plot.dendrite}} \examples{ sex<-sample(c("M","F"),100,TRUE) hair<-sample(c("Blond","Black","Brown","Red"),100,TRUE) eye<-sample(c("Blue","Black","Brown","Green"),100,TRUE) charac<-data.frame(sex=sex,hair=hair,eye=eye) characlist<-makeDendrite(charac) characlist } plotrix/man/listDepth.Rd0000755000176000001440000000073511334502056015014 0ustar ripleyusers\name{listDepth} \alias{listDepth} \title{Find the maximum depth of a list} \description{Descend a list and find the maximum number of levels.} \usage{ listDepth(x) } \arguments{ \item{x}{A list.} } \details{ A possibly nested list of lists is descended to determine the maximum number of levels. Currently used to set up the dimensions of a dendrite plot. } \value{The maximum number of levels in the list.} \keyword{misc} \author{Jim Lemon} \seealso{\link{plot.dendrite}} plotrix/man/lengthKey.Rd0000755000176000001440000000223511324074602015003 0ustar ripleyusers\name{lengthKey} \alias{lengthKey} \title{Key for interpreting lengths in a plot} \description{Key for interpreting lengths in a plot} \usage{ lengthKey(x,y,tickpos,scale) } \arguments{ \item{x,y}{The position of the left end of the key in user units.} \item{tickpos}{The labels that will appear above the key.} \item{scale}{A value that will scale the length of the key.} } \value{nil} \details{ \samp{lengthKey} displays a line with tick marks and the values in \samp{tickpos} above those tickmarks. It is useful when line segments on a plot represent numeric values. Note that if the plot does not have a 1:1 aspect ratio, a length key is usually misleading. } \author{Jim Lemon} \seealso{\link{segments}, \link{arrows}} \examples{ # manufacture a matrix of orientations in radians o<-matrix(rep(pi*seq(0.1,0.8,by=0.1),7),ncol=8,byrow=TRUE) m<-matrix(rnorm(56)+4,ncol=8,byrow=TRUE) # get an empty plot of approximately 1:1 aspect ratio plot(0,xlim=c(0.7,8.3),ylim=c(0.7,7.3),type="n") vectorField(o,m,vecspec="rad") # the scaling usually has to be worked out by trial and error lengthKey(0.3,-0.5,c(0,5,10),0.24) } \keyword{misc} plotrix/man/legendg.Rd0000755000176000001440000000640511365546310014466 0ustar ripleyusers\name{legendg} \alias{legendg} \title{Legend with grouped bars, lines or symbols} \description{Displays a legend with more than one rectangle, symbol or line.} \usage{ legendg(x,y=NULL,legend,fill=NULL,col=par("col"), border="black",lty,lwd,pch=NULL,angle=45,density=NULL, bty="o",bg=par("bg"),box.lwd=par("lwd"),box.lty=par("lty"), box.col=par("fg"),pt.bg=NA,cex=1,pt.cex=cex,pt.lwd=lwd, pt.space=1,xjust=0,yjust=1,x.intersp=1,y.intersp=1, adj=c(0,0.5),text.width=NULL,text.col=par("col"),merge=FALSE, trace=FALSE,plot=TRUE,ncol=1,horiz=FALSE,title=NULL, inset=0,xpd,title.col=text.col) } \arguments{ \item{x,y}{Position of the legend as in \samp{legend}.} \item{legend}{Labels for the legend as in \samp{legend}.} \item{fill}{List of fill colors for the rectangles.} \item{col}{Color(s), perhaps as a list, for the symbols.} \item{border}{Border color for the rectangles.} \item{lty}{Line type, currently ignored and set to 1.} \item{lwd}{Line width, currently ignored.} \item{pch}{List of symbols for the legend.} \item{angle,density}{Currently ignored.} \item{bty}{Legend box type to be displayed.} \item{bg}{Background color for the legend.} \item{box.lwd,box.lty,box.col}{Line width, type and color for the surrounding box.} \item{cex}{Character expansion for text.} \item{pt.bg,pt.cex,pt.lwd}{Background color, character expansion and line width for the symbols.} \item{pt.space}{Spacing for the symbols as a multiplier for \samp{strwidth("O")}.} \item{xjust,yjust}{Justification for the legend.} \item{x.intersp,y.intersp}{x and y character spacing for the legend text.} \item{adj}{Text adjustment.} \item{text.width,text.col}{Width and color of the legend text.} \item{merge}{Whether to merge points and lines.} \item{trace}{Show how the legend is calculated.} \item{plot}{Whether to plot the legend.} \item{ncol}{Number of columns in the legend.} \item{horiz}{Whether to display a horizontal legend.} \item{title}{Title for the legend.} \item{inset}{Inset distances for use with keywords.} \item{xpd}{An optional value for \samp{par(xpd=)}.} \item{title.col}{Color for the legend title.} } \value{ The value returned by \samp{legend} returned invisibly. } \details{ \samp{legendg} calls \samp{legend} to display a legend with a blank space to the left of the labels. It then attempts to display groups of colored rectangles or symbols in that space depending upon the contents of either \samp{fill} or \samp{pch}. These should be in the form of a list with the number of elements equal to the number of labels, and one or more fills or symbols for each label. \samp{legendg} will display up to four fills or symbols next to each label, allowing the user to label a group of these rather than just one per label. } \author{Jim Lemon} \seealso{\link{legend}} \examples{ plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1),type="n", main="Test of grouped legend function") legendg(0.5,0.8,c("one","two","three"),pch=list(1,2:3,4:6), col=list(2,3:4,5:7)) legendg(0.5,0.5,c("one","two","three"),fill=list(2,3:4,5:7)) # fake a line/point with text points legendg(0.2,0.25,c("letter","number"), pch=list(c("-","A","-"),c("-","1","-")), col=list(rep(2,3),rep(3,3))) } \keyword{misc} plotrix/man/ladderplot.Rd0000755000176000001440000000446411642040142015204 0ustar ripleyusers\name{ladderplot} \Rdversion{1.1} \alias{ladderplot} \alias{ladderplot.default} \title{ Ladder Plot } \description{ Makes a ladder plot, similar to \link[MASS]{parcoord} but with more flexibility and graphical options. } \usage{ ladderplot(x, ...) \method{ladderplot}{default}(x, scale=FALSE, col=1, pch=19, lty=1, xlim=c(0.5, ncol(x) + 0.5), ylim=range(x), vertical = TRUE, ordered=FALSE,...) } \arguments{ \item{x}{ A matrix or data frame with at least 2 columns. } \item{scale}{ Logical, if the original data columns should be scaled to the unit (0-1) interval. } \item{col}{ Color values to use for rows of \samp{x}. If longer than 1, its value is recycled. } \item{pch}{ Point type to use. If longer than 1, its value is recycled. } \item{lty}{ Line type to use. If longer than 1, its value is recycled. } \item{xlim, ylim}{ Limits for axes. } \item{vertical}{ Logical, if the orientation of the ladderplot should be vertical or horizontal. } \item{ordered}{ Logical, if the columns in \samp{x} should be ordered. } \item{\dots}{ Other arguments passed to the function \link{stripchart}. } } \details{ The function uses \link{stripchart} to plot 1-D scatter plots for each column in \samp{x}. Then points are joined by lines for each rows of \samp{x}. } \value{ Makes a plot as a side effect. Returns \samp{NULL} invisibly. } \author{ Peter Solymos } \seealso{ \link{lines}, \link{points}, \link{stripchart} Almost identical function: \link[MASS]{parcoord} } \examples{ x<-data.frame(A=c(1:10), B=c(2:11)+rnorm(10)) y<-data.frame(x, C=c(1:10)+rnorm(10)) opar <- par(mfrow=c(1,3)) ladderplot(x) ladderplot(x, col=1:10, vertical=FALSE) ladderplot(y, col=1:10) par(opar) ## examples from parcoord \dontrun{ if (require(MASS)) { opar <- par(mfrow=c(2,3)) z1 <- state.x77[, c(7, 4, 6, 2, 5, 3)] parcoord(z1, main="parcoord state.x77") ladderplot(z1, pch=NA, scale=TRUE, main="ladderplot state.x77 original") ladderplot(z1, main="ladderplot state.x77 original") ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3]) z2 <- log(ir)[, c(3, 4, 2, 1)] parcoord(z2, col = 1 + (0:149)) ladderplot(z2, scale=TRUE, col = 1 + (0:149), main="ladderplot iris original") ladderplot(z2, col = 1 + (0:149)) par(opar) } } } \keyword{ aplot } plotrix/man/labbePlot.Rd0000644000176000001440000000571111564725753014774 0ustar ripleyusers\name{labbePlot} \alias{labbePlot} \title{ Display a L'Abbe plot } \description{ Display the percentages of successes for two conditions to be compared as circles, the area of which is proportional to the number of observations. } \usage{ labbePlot(x,main="L'Abbe plot",xlab="Percent positive response with placebo", ylab="Percent positive response with treatment",labels=NULL,col=NA, circle.mag=0.5,add=FALSE,...) } \arguments{ \item{x}{A list of either 2x2 tables or three element vectors (see Details).} \item{main}{The title of the plot.} \item{xlab,ylab}{The x and y axis labels as in \samp{plot}.} \item{labels}{Text strings that will be displayed in the center of the circles.} \item{col}{A list of colors for the circles.} \item{circle.mag}{A fudge factor for very small or very large numbers of observations.} \item{add}{Whether to add the information in \samp{x} to an existing L'Abbe plot.} \item{...}{additional arguments passed to \samp{plot}.} } \details{ The elements of \samp{x} may be tables in which rows represent the conditions being compared, with the comparison condition first (often "placebo") and the condition of interest (often "intervention") second. The columns represent the counts of successes and failures. The elements of \samp{x} can also be vectors with three numeric values, first the percentage of successes for the comparison condition, second the percentage of successes for the condition of interest and finally the number of observations. Tables and vectors can be mixed. The radius of each circle is the square root of the number of observations multiplied by \samp{circle.mag}. This allows very small numbers of observations to be expanded and very large numbers to be reduced in size. As the area of each circle is proportional to the number of observations, \samp{circle.mag} must be the same for all circles. The user may wish to expand or contract all the circles on a plot so that they will fit within the box. The labels, if not NULL, are displayed on the circles. The function tries to work out whether white or black text will be more easily read based on the background color and displays the text accordingly. } \value{nil} \author{Jim Lemon - thanks to Whitney Melroy for asking for it.} \seealso{\link{draw.circle}} \examples{ # first fake something like the data from a clinical trial didf<-data.frame(subject=1:50,interv=rep(c("therapist","ex-drinker"),each=25), outcome=sample(c("more","less"),50,TRUE)) # make it into a table didf.tab<-table(didf$interv,didf$outcome) # now mix in some raw percentages just for the example didf2<-c(74,46,200) didf3<-c(33,87,500) x<-list(didf.tab,didf2,didf3) labbecol<-list("red","green","blue") labbePlot(x,main="Ex-drinkers vs therapists", xlab="Percent reduced drinking (ex-drinkers)", ylab="Percent reduced drinking (therapists)", labels=list("A","B52","X117"),col=labbecol) labbePlot(list(c(20,40,20)),col=list("purple"),labels=list("Z"),add=TRUE) } \keyword{misc} plotrix/man/kiteChart.Rd0000755000176000001440000001101212110364026014754 0ustar ripleyusers\name{kiteChart} \alias{kiteChart} \title{ Magnitude by position chart. } \description{ Display numeric values as the widths of a polygon along a dimension such as time. } \usage{ kiteChart(x,xlim=NA,ylim=NA,timex=TRUE,main="Kite chart", xlab=ifelse(timex,"Time","Groups"),ylab=ifelse(timex,"Groups","Time"), border=par("fg"),col=NULL,varpos=NA,varlabels=NA,varscale=FALSE, timepos=NA,timelabels=NA,mar=c(5,4,4,4),axlab=c(1,2,3,4), normalize=is.na(varpos[1]),shownorm=TRUE,...) } \arguments{ \item{x}{Numeric matrix or data frame} \item{xlim}{Horizontal extent of the chart. Defaults to 1:dim(x)[2].} \item{ylim}{Vertical extent of the chart. Defaults to 0.5:dim(x)[1]+0.5.} \item{timex}{Whether the "time" axis is x (horizontal) or not.} \item{main,xlab,ylab}{As in \samp{plot}.} \item{border}{The border color(s) for the polygons.} \item{col}{The fill colors for the polygons.} \item{varpos}{Optional positions for the "kite lines". Defaults to 1:dimx[1]. (see Details)} \item{varlabels}{Labels for the rows of values - defaults to the rownames, or if these are missing, varpos[1:dim(x)[1]].} \item{varscale}{Whether to show the maximum extent of each "kite line".} \item{timepos}{The positions of the values along the x axis, usually times, defaulting to 1:dim(x)[2].} \item{timelabels}{Labels for the positions, defaulting to \samp{timepos}.} \item{mar}{Plot margins. These leave space for the normalization multipliers on the right or top side (see Details).} \item{axlab}{Where to put axis tick labels and multipliers. See Details.} \item{normalize}{Whether to scale each row of values to a maximum width of 1.} \item{shownorm}{Whether to display the normalization multipliers.} \item{...}{additional arguments passed to \samp{plot}.} } \details{ \samp{kiteChart} displays each row of \samp{x} as a sequence of widths, allowing the relationships between those values and the dimension along which they occur (usually time) to be illustrated. The values in x are scaled to a maximum polygon width of 1 if \samp{normalize} is TRUE. This is to avoid overlapping of the polygons. There may be some cases where the values can be displayed directly. If normalized, the multipliers will be displayed for each row on the right or top side of the chart unless \samp{shownorm} is FALSE. Remember to specify the \samp{mar} argument if more space at the top is needed. The \samp{axlab} argument allows the user to place the axis tick labels and normalization multipliers on different axes. The default places the tick labels on the bottom and left sides of the plot and the multipliers on the right or top. Using \samp{axlab=c(3,4,1,2)} places the tick labels on the top and right and the multipliers on the left or bottom. The \samp{mar} argument may have to be adjusted. The user can display raw values by default, or by setting \samp{varpos} to TRUE. Setting \samp{varpos} to a vector of positions will place the "kite lines" on those values. If there are no row names and the \samp{varlabels} argument is NA, the values of \samp{varpos} will be used as labels for each "kite line". The maximum extent of each "kite line" can be displayed by setting \samp{varscale} to TRUE. If \samp{varscale} is TRUE, one extra line will be added to the top margin. If \samp{varpos[1]} is not NA, \samp{normalize} is FALSE by default. } \value{The values of \samp{mar} that were current when \samp{kiteChart} was called.} \author{Jim Lemon (Thanks to Michael Bedward for suggestions on the arguments and Nikolaus Lampadariou for the suggestions on displaying raw values)} \seealso{\link{polygon}} \examples{ testmat<-matrix(c(runif(50),sample(1:50,50),rnorm(50)+5, sin(1:50)),ncol=50,byrow=TRUE) kiteChart(testmat,varlabels=c("Uniform","Sample","Normal","Sine"), timepos=seq(1,50,by=5),timex=FALSE) # now show it with kite line maxima kiteChart(testmat,varlabels=c("Uniform","Sample","Normal","Sine"), timepos=seq(1,50,by=5),timex=FALSE,varscale=TRUE) musicmat<-matrix(c(c(0.5,0.4,0.3,0.25,0.2,0.15,0.1,rep(0.05,44))+runif(51,0,0.05), c(0.1,0.2,0.3,0.35,0.4,0.5,0.4,rep(0.5,14),rep(0.4,15),rep(0.3,15))+runif(51,0,0.1), rep(0.15,51)+runif(51,0,0.1), c(rep(0,29),c(0.1,0.2,0.4,0.5,0.3,0.2,rep(0.05,16))+runif(22,0,0.05)), c(rep(0,38),c(rep(0.05,6),0.08,0.15,0.20,0.25,0.2,0.25,0.3)+runif(13,0,0.05))), ncol=51,byrow=TRUE) kiteChart(musicmat,varlabels=c("Swing","Rock","Jazz","Disco","Rap"), main="An utterly imaginary chart of music popularity", timepos=seq(1,51,by=10),timelabels=seq(1950,2000,by=10),mar=c(5,4,4,2), normalize=FALSE) } \keyword{misc} plotrix/man/intersectDiagram.Rd0000755000176000001440000001700311654222430016335 0ustar ripleyusers\name{intersectDiagram} \alias{intersectDiagram} \title{Display set intersections} \description{Display set intersections as rows of rectangles.} \usage{ intersectDiagram(x,pct=FALSE,show.nulls=FALSE,xnames=NULL,sep="+", mar=c(0,0,3,0),main="Intersection Diagram",cex=1,col=NULL, minspacing=NA,all.intersections=FALSE,include=NULL) } \arguments{ \item{x}{A list containing as many numeric vectors as there are sets. The first vector contains the counts or percentages of the elements that are only in one set, the next vector contains the counts or percentages of elements that are in two sets and so on. A matrix of set membership indicators or a two column matrix of object identifiers and attribute identifiers can be passed - see Details.} \item{pct}{Whether to display counts (FALSE) or percentages (TRUE) of the number of entities.} \item{show.nulls}{Whether to display the number of original objects that were not members of any set.} \item{xnames}{Optional user supplied names for the set categories (see Details).} \item{sep}{The separator to use between category names (see Details).} \item{mar}{The margins for the diagram. The margins that were in effect when the function is called are restored.} \item{main}{The title for the diagram.} \item{col}{Colors for the sets (see Details).} \item{cex}{Character expansion for the intersection labels.} \item{minspacing}{The minimum spacing between the rectangles (see Details).} \item{all.intersections}{Whether to display all intersections, even if empty (Dangerous - see Detail).} \item{include}{Which set identifiers to include in the diagram (see Details).} } \details{ \samp{intersectDiagram} displays rows of optionally colored rectangles that represent the intersections of set memberships (attributes) of a set of objects. The topmost row represents the intersections of the fewest sets, and succeeding rows represent the intersections of more sets. If there were objects in the original data set that were not members of any set, any percentages calculated will reflect this. By setting \samp{show.nulls} to TRUE, the counts or percentages of such objects will be displayed below the intersections over an empty rectangle scaled to the count or percentage. Important - If the \samp{all.intersections} argument is TRUE, all intersections will be displayed, whether empty or not (see the example). This is mostly for demonstration purposes, and if the number of sets is large, is likely to produce a very messy diagram. Similarly, sets with large numbers of intersections that are populated will require very large displays to be readable, even if there are small numbers in the intersections. If you would like to see this in action, pass the data frame \samp{setdf} in the \link{categoryReshape} example to \samp{intersectDiagram} with \samp{all.intersections} TRUE. \samp{intersectDiagram} does not attempt to display the set intersections as a pattern of overlapping geometric figures, but rather the relative numbers of objects sharing each intersection. More than three intersecting sets generally produce a complex and difficult to interpret Venn diagram, and this provides an alternative way to display the size of intersections between larger numbers of sets. \samp{intersectDiagram} now allows the user to display only part of the set intersections, which is useful for analyzing very complex intersections. This is controlled by the \samp{include} argument. This defaults to all sets or attributes when \samp{include=NULL}. If one or more of the labels of the sets or attributes is passed, only the intersections containing those labels will be displayed. See examples 2 and 3 below. Each set (attribute) is assigned a color if \samp{col} is not NA. \samp{rainbow} is called if \samp{col} is NULL, otherwise the colors passed are used. For each intersection, the colors representing the sets intersecting are included in the rectangle. The strings displayed on each rectangle are taken from the argument \samp{xnames} unless that is NULL, then the \samp{names} of the intersectList object passed as \samp{x} or returned from the call to \samp{makeIntersectList}. If a matrix or data frame of set membership indicators is passed as \samp{x}, it will be passed to \link{makeIntersectList} for conversion. Each column must represent a set, and the values in the columns must be 0 or 1, or FALSE or TRUE. Similarly, if a matrix or data frame in which the first column is object identifiers and the second column is attributes, this will be passed to \samp{makeIntersectList}. The spacing between the largest rectangles is controlled by \samp{minspacing}. \samp{minspacing} is in units of object counts and defaults to 0.1 times the largest number of objects in an intersection. When the number of objects in different intersections at a given level varies widely, the labels of intersections with few objects may overlap if they are wide relative to the rectangle representing the number of objects. This can be corrected by passing a \samp{minspacing} argument that will increase the space between rectangles and/or decreasing the character size of the labels. If the labels for each set are relatively long, setting \samp{namesep="\n"} may help. Note that if a different separator is passed, that separator must be explicitly passed in any subsequent calls using the same \samp{intersectList} object - see examples 1 to 3 below. } \value{ Returns the intersectionList object invisibly. } \keyword{misc} \author{Jim Lemon} \seealso{\link{makeIntersectList}, \link{getIntersectList}, \link{categoryReshape}} \examples{ # create a matrix where each row represents an element and # a 1 (or TRUE) in each column indicates that the element is a member # of that set. druguse<-matrix(c(sample(c(0,1),200,TRUE,prob=c(0.15,0.85)), sample(c(0,1),200,TRUE,prob=c(0.35,0.65)), sample(c(0,1),200,TRUE,prob=c(0.5,0.5)), sample(c(0,1),200,TRUE,prob=c(0.9,0.1))),ncol=4) colnames(druguse)<-c("Alc","Tob","THC","Amp") druglist<-makeIntersectList(druguse,sep="\n") # first display it as counts intersectDiagram(druglist,main="Patterns of drug use",sep="\n") # then display only the intersections containing "Alc" intersectDiagram(druglist,main="Patterns of drug use (Alcohol users only)", sep="\n",include="alc") # now display only the intersections containing "Amp" intersectDiagram(druglist,main="Patterns of drug use (Speed users only)", sep="\n",include="amp") # then as percent with non.members, passing the initial matrix intersectDiagram(druguse,pct=TRUE,show.nulls=TRUE) # alter the data to have more multiple intersections druguse[which(as.logical(druguse[,1]))[1:40],2]<-1 druguse[which(as.logical(druguse[,1]))[31:70],3]<-1 druguse[,4]<-sample(c(0,1),200,TRUE,prob=c(0.9,0.1)) intersectDiagram(druguse,main="Smaller font in labels", col=c("gray20","gray40","gray60","gray80"),cex=0.8) # transform the spacing - usually makes it too close, first try minspacing intersectDiagram(druguse,col="gray",main="Minimum spacing = 30 cases", minspacing=30) # then try cex - may need both for large differences intersectDiagram(druguse,main="Very boring single color",col="gray",cex=0.8) # create a matrix with empty intersections druguse<-matrix(c(sample(c(0,1),20,TRUE), sample(c(0,1),20,TRUE), sample(c(0,1),20,TRUE), sample(c(0,1),20,TRUE)),ncol=4) # show only the populated intersections intersectDiagram(druguse,main="Display only populated intersections") # show all intersections intersectDiagram(druguse,main="Display empty intersections",all.intersections=TRUE) } plotrix/man/hexagon.Rd0000755000176000001440000000167511334501730014507 0ustar ripleyusers\name{hexagon} \alias{hexagon} \title{Draw a hexagon} \description{ Draws a hexagon on the current graphic device } \usage{ hexagon(x,y,unitcell=1,col=NA,border="black") } \arguments{ \item{x,y}{x and y position of the bottom left corner of the square that would pack into the same space as the hexagon.} \item{unitcell}{The dimension of the side of the abovementioned square.} \item{col}{The color to fill the hexagon - default is no fill.} \item{border}{The color of the perimeter of the hexagon.} } \note{ Draws a hexagon with the same center as a square that would pack into the same dimensions as the hexagon. That is, given a grid of squares with alternate rows shifted one half the length of the sides, the hexagons drawn would be close packed. Its use in the plotrix package is to provide an alternative unit cell for the \samp{color2D.matplot} function. } \value{nil} \author{Jim Lemon} \seealso{\link{color2D.matplot}} \keyword{misc} plotrix/man/gradient.rect.Rd0000755000176000001440000000330211334501716015600 0ustar ripleyusers\name{gradient.rect} \title{Display a rectangle filled with an arbitrary color gradient} \usage{ gradient.rect(xleft,ybottom,xright,ytop,reds,greens,blues,col=NULL, nslices=50,gradient="x",border=par("fg")) } \alias{gradient.rect} \arguments{ \item{xleft,ybottom,xright,ytop}{Positions of the relevant corners of the desired rectangle, as in \samp{rect}.} \item{reds,greens,blues}{vectors of the values of the color components either as 0 to 1 or ,if any value is greater than 1, 0 to 255.} \item{col}{Vector of colors. If supplied, this takes precedence over \samp{reds, greens, blues} and \samp{nslices} will be set to its length.} \item{nslices}{The number of sub-rectangles that will be drawn.} \item{gradient}{whether the gradient should be horizontal (x) or vertical.} \item{border}{The color of the border around the rectangle (NA for none).} } \description{ \samp{gradient.rect} draws a rectangle consisting of \samp{nslices} subrectangles of the colors in \samp{col} or those returned by \samp{color.gradient} if \samp{col} is NULL. The rectangle is 'sliced' in the direction specified by \samp{gradient}. } \value{the vector of hexadecimal color values from \samp{color.gradient} or \samp{col}.} \author{Jim Lemon} \examples{ # get an empty box plot(0:10,type="n",axes=FALSE) # run across the three primaries gradient.rect(1,0,3,6,reds=c(1,0), greens=c(seq(0,1,length=10),seq(1,0,length=10)), blues=c(0,1),gradient="y") # now a "danger gradient" gradient.rect(4,0,6,6,c(seq(0,1,length=10),rep(1,10)), c(rep(1,10),seq(1,0,length=10)),c(0,0),gradient="y") # now just a smooth gradient across the bar gradient.rect(7,0,9,6,col=smoothColors("red",38,"blue"),border=NA) } \keyword{misc} plotrix/man/get_axispos3d.Rd0000755000176000001440000000100011441424326015614 0ustar ripleyusers\name{get_axispos3d} \alias{get_axispos3d} \title{ Get axis positions on a 3D plot } \description{ Calculate the axis positions on a 3D plot. } \usage{ get_axispos3d(edge,pmat,at,pos=NULL, dist=0) } \arguments{ \item{edge}{ which axis to calculate.} \item{pmat}{ matrix to transform coordinates. } \item{at}{ position on the axis. } \item{pos}{ position of the axis relative to the other axes. } \item{dist}{ Offset of the axis. } } \value{A position in 2D coordinates} \author{Ben Bolker} \keyword{misc} plotrix/man/getMarginWidth.Rd0000755000176000001440000000222711334501600015761 0ustar ripleyusers\name{getMarginWidth} \alias{getMarginWidth} \title{Find the margin width necessary to fit text or a legend next to a plot} \description{ Calculates the margin width necessary to fit text or a legend next to a plot. } \usage{ getMarginWidth(side=4,labels,is.legend=FALSE) } \arguments{ \item{side}{Which side of the plot (as in axis).} \item{labels}{The text to place next to the plot.} \item{is.legend}{Whether the text is in a legend or not.} } \details{ \samp{getMarginWidth} reads parameters about the current plot and calculates the left or right (default) margin necessary to fit the strings passed as \samp{labels} or a legend containing those strings. } \value{ A two element list containing the number of margin lines necessary to fit the text or legend and the horizontal center of the margin in user units. } \author{Jim Lemon} \examples{ plot(rnorm(10)) newmarinfo<-getMarginWidth(labels=c("Long label","Even longer label")) oldmar<-par("mar") par(mar=c(oldmar[1:3],newmarinfo$newmar)) plot(rnorm(10)) par(xpd=TRUE) text(rep(newmarinfo$marcenter,2),c(0.5,-0.5), c("Long label","Even longer label")) par(mar=oldmar,xpd=FALSE) } \keyword{misc} plotrix/man/getIntersectList.Rd0000755000176000001440000000402511644507376016362 0ustar ripleyusers\name{getIntersectList} \alias{getIntersectList} \title{Enter a set intersection list} \description{Enter the information for a set intersection display.} \usage{ getIntersectList(nelem,xnames=NULL,sep="+") } \arguments{ \item{nelem}{The number of sets for which the intersections will be displayed.} \item{xnames}{The labels for the set intersections. The function creates names from combinations of the first \samp{nelem} capital letters if none are given.} \item{sep}{The separator to use when calling \samp{paste}.} } \details{ \samp{getIntersectList} allows the user to manually enter the counts of set intersections rather than build this information from a matrix of data. It is probably most useful for producing an intersection diagram when the counts of the intersections are already known, or when the values are proportions rather than counts as in the example. It is very helpful when there are large numbers of elements, as the \samp{makeIntersectList} function runs very slowly. } \value{A list of the counts of elements in the set intersections.} \author{Jim Lemon} \seealso{\link{makeIntersectList}, \link{intersectDiagram}} \examples{ # this example is from a haplotype mapping problem submitted by Mao Jianfeng \dontrun{ hapIntList<- getIntersectList(3,xnames=c("hap.Pd","hap.Pt","hap.Py")) # enter the data as follows: # Number of elements in hap.Pd - 1: 27.586 # Number of elements in hap.Pt - 1: 20.689 # Number of elements in hap.Py - 1: 31.035 # Number of elements in hap.Pd-hap.Pt - 1: 10.345 # Number of elements in hap.Pd-hap.Py - 1: 10.345 # Number of elements in hap.Pt-hap.Py - 1: 0 # Number of elements in hap.Pd-hap.Pt-hap.Py - 1: 0 # Total number of elements - 1: 100 } hapIntList<-structure(list(structure(c(27.586, 20.689, 31.035), .Names = c("hap.Pd","hap.Pt","hap.Py")), structure(c(10.345, 10.345, 0), .Names = c("hap.Pd-hap.Pt","hap.Pd-hap.Py","hap.Pt-hap.Py")), structure(0, .Names = "hap.Pd-hap.Pt-hap.Py"),100), class = "intersectList") intersectDiagram(hapIntList) } \keyword{misc} plotrix/man/getFigCtr.Rd0000755000176000001440000000172211411572406014731 0ustar ripleyusers\name{getFigCtr} \title{Get coordinates in the figure region in user units.} \description{ Calculates the coordinates of a proportional point of the figure region in user units.} \usage{ getFigCtr(pos=c(0.5,0.5)) } \arguments{ \item{pos}{The proportion of the figure region to find (see Details).} } \alias{getFigCtr} \details{ \samp{getFigCtr} reads parameters about the current plot and calculates the vertical and horizontal centers of the figure region by default. This is typically useful for placing a centered title on plots where the left and right margins are very different. By changing \samp{pos}, any proportional points of the figure region can be returned. For example, \samp{pos=c(0,0)} will return the left and bottom coordinates of the figure region. } \value{A two element vector containing the coordinates of the center of the figure region in user units.} \author{Jim Lemon (thanks to Karl Brand for the adjustable coordinates)} \keyword{misc} plotrix/man/get.triprop.Rd0000755000176000001440000000173411334501672015334 0ustar ripleyusers\name{get.triprop} \alias{get.triprop} \title{Enter three proportion data - usually soil textures} \usage{ get.triprop(use.percentages=FALSE,cnames=c("1st","2nd","3rd")) } \arguments{ \item{use.percentages}{Logical - whether to treat the entries as percentages and scale to proportions.} \item{cnames}{column names for the resulting three column matrix.} } \description{ \samp{get.triprop} allows the user to enter triplets of proportions or percentages of three components such as sand, silt and clay in soils. } \details{ The three proportions of each row must sum to 100 or 1 within 1\% or the function will warn the operator.} \value{A matrix of the components of one or more observations.} \author{Jim Lemon} \seealso{\link{triax.plot}, \link{soil.texture}} \examples{ if(dev.interactive()) { # get some proportions newsp<-get.triprop() # show the triangle triax.frame(main="Test triax.plot") # now plot the observations triax.points(newsp) } } \keyword{misc} plotrix/man/get.soil.texture.Rd0000755000176000001440000000154711334501624016301 0ustar ripleyusers\name{get.soil.texture} \alias{get.soil.texture} \title{Enter soil texture data} \usage{ get.soil.texture(use.percentages=FALSE,cnames=c("sand","silt","clay")) } \arguments{ \item{use.percentages}{Logical - whether to treat the entries as percentages and scale to proportions.} \item{cnames}{column names for the resulting three column matrix.} } \description{ \samp{get.soil.texture} calls \samp{get.triprop} to allow the user to enter soil textures as the proportions or percentages of three components, sand, silt and clay. } \value{A matrix of the components of one or more soil samples.} \author{Sander Oom and Jim Lemon} \seealso{\link{soil.texture},\link{get.triprop}} \examples{ if(dev.interactive()) { newsp<-get.soil.texture() # show the soil triangle soil.texture() # now plot the observations show.soil.texture(newsp) } } \keyword{misc} plotrix/man/get.segs.Rd0000755000176000001440000000206511324074324014572 0ustar ripleyusers\name{get.segs} \alias{get.segs} \title{Calculate the midpoints and limits for a centipede plot} \description{ Calculates midpoints and limits for a list or data frame for use with centipede.plot. } \usage{ get.segs(x,mct="mean",lower.limit="std.error",upper.limit=lower.limit) } \arguments{ \item{x}{a list or data frame.} \item{mct}{The name of the function to calculate midpoints.} \item{lower.limit,upper.limit}{The names of the function(s) to calculate lower and upper limits.} } \details{ \samp{get.segs} calls the functions whose names are passed to calculate midpoints and limits for each list element or data frame column. The user can define special functions for the central and dispersion measures if desired. } \value{A matrix with four rows and as many columns as were in the object \samp{x}. The first row contains the midpoint values, the second and third the lower and upper limit values respectively and the fourth row the number of valid observations in the columns.} \author{Jim Lemon} \seealso{\link{centipede.plot}} \keyword{misc} plotrix/man/get.gantt.info.Rd0000755000176000001440000000173011324074174015701 0ustar ripleyusers\name{get.gantt.info} \alias{get.gantt.info} \title{Gather the information to create a Gantt chart} \description{ Allows the user to enter the information for a Gantt chart. } \usage{ get.gantt.info(format="\%Y/\%m/\%d") } \arguments{ \item{format}{the format to be used in entering dates/times. Defaults to YYYY/mm/dd. See \link{strptime} for various date/time formats.} } \value{ The list used to create the chart. Elements are: \item{labels}{The task labels to be displayed at the left of the chart.} \item{starts,ends}{The task starts/ends as POSIXct dates/times.} \item{priorities}{Task priorities as integers in the range 1 to 10. There can be less than 10 levels of priority, but if priorities do not start at 1 (assumed to be the highest), the default priority colors will be calculated from 1.} } \author{Jim Lemon} \seealso{\link{gantt.chart}} \examples{ cat("Enter task times using HH:MM (hour:minute) format\n") get.gantt.info("\%H:\%M") } \keyword{misc} plotrix/man/get.breaks.Rd0000755000176000001440000000120011324074106015064 0ustar ripleyusers\name{get.breaks} \alias{get.breaks} \title{Get the breakpoints for a weighted histogram} \description{ Gets the breakpoints for a weighted histogram. } \usage{ get.breaks(x,breaks) } \arguments{ \item{x}{A numeric vector.} \item{breaks}{Either the name of the function to calculate breakpoints, the number of categories or a vector of breakpoints.} } \details{ \samp{get.breaks} either calls the same functions as \samp{hist} to get breakpoints or calculates a given number or just returns \samp{breaks} if they are already specified. } \value{A vector of breakpoints.} \author{Jim Lemon} \seealso{\link{hist}} \keyword{misc} plotrix/man/gap.plot.Rd0000755000176000001440000000756611361053620014607 0ustar ripleyusers\name{gap.plot} \alias{gap.plot} \title{Display a plot with one or two gaps (missing ranges) on one axis} \description{ Displays a plot with one or two missing ranges on one of the axes. } \usage{ gap.plot(x,y,gap,gap.axis="y",bgcol="white",breakcol="black",brw=0.02, xlim,ylim,xticlab,xtics=NA,yticlab,ytics=NA,lty=rep(1,length(x)), col=rep(par("col"),length(x)),pch=rep(1,length(x)),add=FALSE,...) } \arguments{ \item{x,y}{data values} \item{gap}{the range(s) of values to be left out} \item{gap.axis}{whether the gaps are to be on the x or y axis} \item{bgcol}{the color of the plot background} \item{breakcol}{the color of the "break" marker} \item{brw}{break width relative to plot width} \item{xlim,ylim}{the plot limits.} \item{xticlab}{labels for the x axis ticks} \item{xtics}{position of the x axis ticks} \item{yticlab}{labels for the y axis ticks} \item{ytics}{position of the y axis ticks} \item{lty}{line type(s) to use if there are lines} \item{col}{color(s) in which to plot the values} \item{pch}{symbols to use in plotting.} \item{add}{whether to add values to an existing plot.} \item{...}{arguments passed to \samp{plot} and \samp{points}.} } \value{nil} \details{ Displays a plot omitting one or two ranges of values on one axis. Typically used when there is a relatively large gap or two in the overall range of one set of values, often because of outliers. The function warns the user if any values have been omitted by being in the "gap". See \link{axis.break} for a brief discussion of plotting on discontinuous coordinates. To add more data series to a gap plot, call \samp{gap.plot} with \samp{add = TRUE}. The same \samp{gap} and \samp{gap.axis} arguments as in the initial call must be passed or the data will not be displayed correctly. Remember to pass an explicit \samp{xlim} or \samp{ylim} to the initial call if the added data exceed the range of the data initially displayed. Also remember to subtract the width(s) of the gap(s) if you are passing an explicit \samp{xlim} or \samp{ylim}. Because the gaps take up some space, it is possible to have a data value that is just below a gap plotted in the gap. The answer is to make the lower gap limit a little higher if this is a problem. If at least four values are passed in \samp{gap}, the first four will be used to calculate two "gaps" in the plot instead of one. The function does not check whether these values are sensible, so it is quite easy to ask for a very silly plot. The default ticks are usually not ideal, and most users will want to pass their own tick positions and perhaps labels. Note that \samp{lines} appears to use only the first \samp{col} and \samp{lty} argument value, so if you must have lines with different colors and types, use \samp{add=TRUE} and add them separately (see the third example for the problem and the solution). } \author{Jim Lemon and Ben Bolker (thanks to Zheng Lu for the "add" idea, and Art Roberts for helping to get the gaps right.)} \seealso{\link{gap.barplot}, \link{axis.break}} \examples{ twogrp<-c(rnorm(5)+4,rnorm(5)+20,rnorm(5)+5,rnorm(5)+22) gpcol<-c(2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5) gap.plot(twogrp,gap=c(8,16),xlab="Index",ylab="Group values", main="Gap on Y axis",col=gpcol) gap.plot(twogrp,rnorm(20),gap=c(8,16),gap.axis="x",xlab="X values", xtics=c(4,7,17,20),ylab="Y values",main="Gap on X axis with added lines") gap.plot(c(seq(3.5,7.5,by=0.5),seq(16.5,22.5,by=0.5)), rnorm(22),gap=c(8,16),gap.axis="x",type="l",add=TRUE,col=2,) gap.plot(twogrp,gap=c(8,16,25,35), xlab="X values",ylab="Y values",xlim=c(1,30),ylim=c(0,25), main="Test two gap plot with the lot",xtics=seq(0,30,by=5), ytics=c(4,6,18,20,22,38,40,42), lty=c(rep(1,10),rep(2,10)), pch=c(rep(2,10),rep(3,10)), col=c(rep(2,10),rep(3,10)), type="b") gap.plot(21:30,rnorm(10)+40,gap=c(8,16,25,35),add=TRUE, lty=rep(3,10),col=rep(4,10),type="l") } \keyword{misc} plotrix/man/gap.boxplot.Rd0000755000176000001440000000632111324074002015300 0ustar ripleyusers\name{gap.boxplot} \alias{gap.boxplot} \title{Display a boxplot with a gap (missing range)} \description{ Displays a boxplot with a missing range. } \usage{ gap.boxplot(x,...,gap=list(top=c(NA,NA),bottom=c(NA,NA)), range=1.5,width=NULL,varwidth=FALSE,notch=FALSE,outline=TRUE, names,ylim=NA,plot=TRUE,border=par("fg"),col=NULL,log="", axis.labels=NULL,pars=list(boxwex=0.8,staplewex=0.5,outwex=0.5), horizontal=FALSE,add=FALSE,at=NULL,main=NULL) } \arguments{ \item{x}{numeric vector or a list of vectors} \item{...}{arguments passed to \link{boxplot}.} \item{gap}{the range(s) to be omitted - a list with two components, \samp{top} and \samp{bottom} each specifying a range to omit. The default range of \samp{c(NA,NA)} means no omitted range} \item{range}{how far to extend the whiskers, (see \link{boxplot})} \item{width}{the relative widths of the boxes} \item{varwidth}{if TRUE, box widths are proportional to the square roots of the number of observations} \item{notch}{whether to display the confidence intervals for the median as notches} \item{outline}{whether to display outliers} \item{names}{optional names to display beneath each boxplot} \item{ylim}{Optional y axis limits for the plot.} \item{boxwex}{scale factor for box widths} \item{staplewex}{staple width proportional to box width} \item{outwex}{outlier line width} \item{plot}{dummy argument for consistency with \samp{boxplot} - always plots} \item{border}{optional color(s) for the box lines} \item{col}{optional color(s) to fill the boxes} \item{log}{whether to use a log scale - currently does nothing} \item{axis.labels}{Optional axis labels.} \item{pars}{optional parameters for consistency with \samp{boxplot}} \item{horizontal}{whether to plot horizontal boxplots - currently does nothing} \item{add}{whether to add the boxplot(s) to a current plot - currently does nothing} \item{at}{optional horizontal locations for the boxplots - currently does nothing} \item{main}{a title for the plot} } \value{ A list with the same structure as returned by \samp{boxplot}, except that the values of elements beyond the gap(s) have their true positions on the plot rather than the original values. } \details{ Displays boxplot(s) omitting range(s) of values on the top and/or bottom of the plot. Typically used when there are outliers far from the boxes. See \link{boxplot} for more detailed descriptions of the arguments. If the gaps specified include any of the values in the \samp{stats} matrix returned from \samp{boxplot}, the function will exit with an error message. This prevents generation of NAs in indexing operations, which would fail anyway. A gap can include part of a box, but it is unlikely that this would be intended by the user. See \link{axis.break} for a brief discussion of plotting on discontinuous coordinates. } \author{Jim Lemon} \seealso{\link{gap.barplot},\link{gap.plot}} \examples{ twovec<-list(vec1=c(rnorm(30),-6),vec2=c(sample(1:10,40,TRUE),20)) gap.boxplot(twovec,gap=list(top=c(12,18),bottom=c(-5,-3)), main="Show outliers separately") if(dev.interactive()) par(ask=TRUE) gap.boxplot(twovec,gap=list(top=c(12,18),bottom=c(-5,-3)),range=0, main="Include outliers in whiskers") par(ask=FALSE) } \keyword{misc} plotrix/man/gap.barplot.Rd0000755000176000001440000000333511546606100015264 0ustar ripleyusers\name{gap.barplot} \alias{gap.barplot} \title{ Display a barplot with a gap (missing range) on one axis } \description{ Displays a barplot with a missing range. } \usage{ gap.barplot(y,gap,xaxlab,xtics,yaxlab,ytics,xlim=NA,ylim=NA,xlab=NULL, ylab=NULL,horiz=FALSE,col,...) } \arguments{ \item{y}{a vector of data values} \item{gap}{the range of values to be left out} \item{xaxlab}{labels for the x axis ticks} \item{xtics}{position of the x axis ticks} \item{yaxlab}{labels for the y axis ticks} \item{ytics}{position of the y axis ticks} \item{xlim}{Optional x limits for the plot} \item{ylim}{optional y limits for the plot} \item{xlab}{label for the x axis} \item{ylab}{label for the y axis} \item{horiz}{whether to have vertical or horizontal bars} \item{col}{color(s) in which to plot the values} \item{...}{arguments passed to \samp{barplot}.} } \value{ The center positions of the bars. } \details{ Displays a barplot omitting a range of values on the X or Y axis. Typically used when there is a relatively large gap in the range of values represented as bar heights. See \link{axis.break} for a brief discussion of plotting on discontinuous coordinates. If the user does not ask for specific y limits, the function will calculate limits based on the range of the data values. If passing specific limits, remember to subtract the gap from the upper limit. } \author{Jim Lemon} \seealso{\link{gap.barplot}} \examples{ twogrp<-c(rnorm(10)+4,rnorm(10)+20) gap.barplot(twogrp,gap=c(8,16),xlab="Index",ytics=c(3,6,17,20), ylab="Group values",main="Barplot with gap") gap.barplot(twogrp,gap=c(8,16),xlab="Index",ytics=c(3,6,17,20), ylab="Group values",horiz=TRUE,main="Horizontal barplot with gap") } \keyword{misc} plotrix/man/gantt.chart.Rd0000755000176000001440000001151311627366350015277 0ustar ripleyusers\encoding{latin1} \name{gantt.chart} \alias{gantt.chart} \title{Display a Gantt chart} \description{ Displays a Gantt chart with priority coloring } \usage{ gantt.chart(x=NULL,format="\%Y/\%m/\%d",xlim=NULL,taskcolors=NULL, priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format="\%Y/\%m/\%d", half.height=0.25,hgrid=FALSE,main="",xlab="",cylindrical=FALSE,label.cex=1, border.col=NA,priority.label="Priorities",priority.extremes=c("High","Low")) } \arguments{ \item{x}{a list of task labels, start/end times and task priorities as returned by \samp{get.gantt.info}. If this is not present, \link{get.gantt.info} will be called.} \item{format}{the format to be used in entering dates/times (see \link{strptime}).} \item{xlim}{the horizontal limits of the plot.} \item{taskcolors}{a vector of colors used to illustrate task priority.} \item{priority.legend}{Whether to display a priority color legend.} \item{vgridpos}{optional positions of the vertical grid lines.} \item{vgridlab}{optional labels for the vertical grid lines.} \item{vgrid.format}{format for the vertical grid labels.} \item{half.height}{the proportion of the spacing between task bars that will be filled by the bar on each side - 0.5 will leave no space.} \item{hgrid}{logical - whether to display grid lines between the bars.} \item{main}{the title of the plot - note that this is actually displayed using \samp{mtext}.} \item{xlab}{horizontal axis label - usually suppressed.} \item{cylindrical}{Whether to give the bars a cylindrical appearance.} \item{label.cex}{Relative size for the task labels at the left side.} \item{border.col}{The color for an optional border for the bars (NA=none).} \item{priority.label}{Label for the priority color legend.} \item{priority.extremes}{Labels for each end of the priority color legend.} } \value{ The list used to create the chart - see \link{get.gantt.info} for details. This can be saved and reused rather than manually entering the information each time the chart is displayed. } \details{ If task priority colors are not wanted, set \samp{taskcolors} to a single value to suppress the coloring. If this is not done, \samp{rainbow} will be called to generate a different color for each task. If colors other than \samp{rainbow} are wanted, remember to pass enough colors for one to the lowest (highest numerically) priority. There can now be more than one time interval for each task. If there is, more than one bar will be displayed for each interval, which may not be a task at all, but rather intervals related to the labels. Colors can be specified for labels or intervals and if there are not as many colors as intervals, the first "number of unique labels" colors will be assigned to each unique label. This should make every bar for each label the same color, but be aware that the colors will be distributed in alphabetical order of the entity labels. If there are at least as many taskcolors as intervals, they will be assigned to intervals in the order of the \samp{taskcolors} vector. The examples should make this clearer. Since \samp{gantt.chart} can be used to display things other than prioritized tasks, the labels for the priority legend can now be specified. } \author{Jim Lemon (original by Scott Waichler - features by Ulrike Gromping - added label colors by Nicolas Immelman)} \seealso{\link{get.gantt.info}} \examples{ Ymd.format<-"\%Y/\%m/\%d" gantt.info<-list(labels= c("First task","Second task","Third task","Fourth task","Fifth task"), starts= as.POSIXct(strptime( c("2004/01/01","2004/02/02","2004/03/03","2004/05/05","2004/09/09"), format=Ymd.format)), ends= as.POSIXct(strptime( c("2004/03/03","2004/05/05","2004/05/05","2004/08/08","2004/12/12"), format=Ymd.format)), priorities=c(1,2,3,4,5)) vgridpos<-as.POSIXct(strptime(c("2004/01/01","2004/02/01","2004/03/01", "2004/04/01","2004/05/01","2004/06/01","2004/07/01","2004/08/01", "2004/09/01","2004/10/01","2004/11/01","2004/12/01"),format=Ymd.format)) vgridlab<- c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") gantt.chart(gantt.info,main="Calendar date Gantt chart (2004)", priority.legend=TRUE,vgridpos=vgridpos,vgridlab=vgridlab,hgrid=TRUE) # if both vgidpos and vgridlab are specified, # starts and ends don't have to be dates info2<-list(labels=c("Jim","Joe","Jim","John","John","Jake","Joe","Jed","Jake"), starts=c(8.1,8.7,13.0,9.1,11.6,9.0,13.6,9.3,14.2), ends=c(12.5,12.7,16.5,10.3,15.6,11.7,18.1,18.2,19.0)) gantt.chart(info2,vgridlab=8:19,vgridpos=8:19, main="All bars the same color",taskcolors="lightgray") gantt.chart(info2,vgridlab=8:19,vgridpos=8:19, main="A color for each label",taskcolors=c(2,3,7,4,8)) gantt.chart(info2,vgridlab=8:19,vgridpos=8:19, main="A color for each interval - with borders", taskcolors=c(2,3,7,4,8,5,3,6,"purple"),border.col="black") } \keyword{misc} plotrix/man/furc.Rd0000755000176000001440000000205611512555115014013 0ustar ripleyusers\name{furc} \alias{furc} \title{Plot a dendrite} \description{Plot one level of a dendrogram displaying two or more mutually exclusive attributes.} \usage{ furc(x,xpos,yrange,toplevel,cex=1) } \arguments{ \item{x}{A \samp{dendrite} object containing the counts of objects having combinations of mutually exclusive attributes.} \item{xpos}{The horizontal position on the plot to display the current level of the dendrogram.} \item{yrange}{The range of values in which the current level of the dendrogram will be displayed.} \item{toplevel}{A flag for the function to know whether it is at the top level of the dendrogram or not. Do not change this argument.} \item{cex}{The character expansion to use in the display.} } \details{ \samp{furc} displays one \emph{furc}ation of the dendrogram. A furcation is a single box displaying its label and count that may split into finer divisions. If so, \samp{furc} calls itself for each furcation until there are no more splits. } \value{nil} \keyword{misc} \author{Jim Lemon} \seealso{\link{plot.dendrite}} plotrix/man/fullaxis.Rd0000755000176000001440000000403011430230570014667 0ustar ripleyusers\name{fullaxis} \alias{fullaxis} \title{Add an axis with a line to the edge of the plot} \description{ As \samp{axis}, but draws a "box" line in the same color as the axis. } \usage{ fullaxis(side=1,at=NULL,labels=TRUE,line=NA,pos=NA,outer=FALSE, font=NA,lty="solid",lwd=1,lwd.ticks=lwd,col=NULL,col.ticks=NULL, hadj=NA,padj=NA,...) } \arguments{ \item{side}{The side of the plot to draw the axis} \item{at}{Optional positions in user units for the tick marks.} \item{labels}{Optional labels for the tick marks.} \item{line}{Optional line into the margin.} \item{pos}{Optional position in user units for the axis. Defaults to the edge.} \item{outer}{Whether to use the outer margin as for \samp{axis}.} \item{font}{Font for the labels.} \item{lty}{Line type.} \item{lwd}{Line width for the axis.} \item{lwd.ticks}{Line width for the ticks.} \item{col}{color for the axis and tick marks. See Details for label color.} \item{col.ticks}{Color for the tick marks if different from the axis.} \item{hadj,padj}{Justification for the labels. See \samp{axis}.} \item{...}{Further arguments passed to \samp{axis}.} } \details{ \samp{fullaxis} draws a line to the edges of the plot and then calls \samp{axis} to draw an axis. \samp{fullaxis} is mainly useful for drawing a colored axis on a boxed plot. In order to get the tick labels the same color as the axis and ticks, pass the \samp{col.axis} argument (as part of ...) as well as \samp{col}. See the example for some useful tips. } \value{ The positions of the tick marks in user units. } \author{ Jim Lemon } \seealso{ \link{axis}} \examples{ plot(runif(20,-1,1),runif(20,-1,1),xlim=c(-1,1.5),main="Demo of fullaxis", xlab="X",ylab="Y",axes=FALSE) fullaxis(1,col="red",col.axis="red") fullaxis(2,col="blue",col.axis="blue") fullaxis(4,at=c(-0.5,0,0.5),labels=c("Negative","Zero","Positive"),pos=1.2, col="green",las=1) # add a top line to complete the "box" xylim<-par("usr") segments(xylim[1],xylim[4],xylim[2],xylim[4]) } \keyword{misc} plotrix/man/floating.pie.Rd0000755000176000001440000000407412112010554015423 0ustar ripleyusers\name{floating.pie} \alias{floating.pie} \title{Display a floating pie chart} \description{ Displays a pie chart at an arbitrary position on an existing plot } \usage{ floating.pie(xpos,ypos,x,edges=200,radius=1,col=NULL,startpos=0, shadow=FALSE,shadow.col=c("#ffffff","#cccccc"),...) } \arguments{ \item{xpos,ypos}{x and y position of the center of the pie chart} \item{x}{a numeric vector for which each value will be a sector} \item{edges}{the number of lines forming a circle} \item{radius}{the radius of the pie in user units} \item{col}{the colors of the sectors - defaults to \samp{rainbow}} \item{startpos}{The starting position for drawing sectors in radians.} \item{shadow}{Logical - whether to draw a shadow} \item{shadow.col}{Colors to use for a shadow.} \item{...}{graphical parameters passed to \samp{polygon}} } \details{ \samp{floating.pie} displays a pie chart with an optional shadow on an existing plot (see \samp{polygon.shadow}). } \value{ The bisecting angle of the sectors in radians. Useful for placing text labels for each sector. } \note{ As with most pie charts, simplicity is essential. Trying to display a complicated breakdown of data rarely succeeds. } \author{Jim Lemon} \seealso{\link{pie.labels}, \link{boxed.labels}, \link{polygon.shadow}} \examples{ plot(1:5,type="n",main="Floating Pie test",xlab="",ylab="",axes=FALSE) box() polygon(c(0,0,5.5,5.5),c(0,3,3,0),border="#44aaff",col="#44aaff") floating.pie(1.7,3,c(2,4,4,2,8),radius=0.5, col=c("#ff0000","#80ff00","#00ffff","#44bbff","#8000ff")) floating.pie(3.1,3,c(1,4,5,2,8),radius=0.5, col=c("#ff0000","#80ff00","#00ffff","#44bbff","#8000ff")) floating.pie(4,1.5,c(3,4,6,7),radius=0.5, col=c("#ff0066","#00cc88","#44bbff","#8000ff")) draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(4,2.3,radius=0.04,col="white") draw.circle(4.07,2.55,radius=0.04,col="white") draw.circle(4.03,2.85,radius=0.04,col="white") text(c(1.7,3.1,4),c(3.7,3.7,3.7),c("Pass","Pass","Fail")) } \keyword{misc} plotrix/man/feather.plot.Rd0000755000176000001440000000411511755433316015454 0ustar ripleyusers\name{feather.plot} \alias{feather.plot} \title{ Display vectors along a horizontal reference line } \description{ Displays vectors along a line usually representing time or position. } \usage{ feather.plot(r,theta,xpos,yref=0,use.arrows=TRUE, col.refline="lightgray",fp.type="s",main="",xlab="",ylab="", xlabels=NULL,...) } \arguments{ \item{r}{radii of vectors} \item{theta}{direction of vectors in radians} \item{xpos}{where to start each vector along the reference line} \item{yref}{vertical position to place the reference line} \item{use.arrows}{whether to put arrow heads on the ends of the vectors} \item{col.refline}{the color of the reference line} \item{fp.type}{whether to use "standard" coordinates (begin at the right and move counterclockwise) or "meteorological" coordinates (begin at the top and move clockwise) when interpreting the values of \samp{theta}} \item{main}{the title of the plot} \item{xlab}{the label for the reference line} \item{ylab}{the label for the vertical axis} \item{xlabels}{optional labels for the reference line} \item{...}{additional arguments passed to \samp{arrows} or \samp{segments}} } \details{ This function places vectors of length \samp{r} and angle \samp{theta} along a reference line that may represent time or position or some other value. The user is responsible for spacing the vectors so that they do not overlap if this is desired. Feather plots are typically wider than high. The user will probably want to specify a graphics device that doesn't leave lots of blank space above and below the plot. } \value{nil} \author{Jim Lemon, Eduardo Klein} \seealso{\link{spread.labels}} \examples{ x11(width=8,height=3) r<-0.6+rnorm(24)/5 theta<-c(seq(15*pi/16,pi/16,length.out=12), seq(17*pi/16,31*pi/16,length.out=12)) feather.plot(r,theta,xlabels=1:24, main="Standard Coordinates",xlab="Time",ylab="Value") # rearrange theta for meteorological coordinates feather.plot(r,c(theta[19:24],rev(theta[7:18]),theta[1:6]),xlabels=1:24,fp.type="m", main="Meteorological Coordinates",xlab="Time",ylab="Value") dev.off() } \keyword{misc} plotrix/man/fan.plot.Rd0000755000176000001440000000341412076476777014622 0ustar ripleyusers\name{fan.plot} \alias{fan.plot} \title{ Display a fan plot } \description{ Displays numerical values as the arcs of overlapping sectors. } \usage{ fan.plot(x,edges=200,radius=1,col=NULL,align.at=NULL,max.span=NULL, labels=NULL,labelpos=NULL,label.radius=1.2,align="left",shrink=0.02, main="",ticks=NULL,include.sumx=FALSE,...) } \arguments{ \item{x}{Vector of numbers.} \item{edges}{The number of edges with which to draw a circle.} \item{radius}{The radius of the sectors.} \item{col}{The colors with which to fill the sectors.} \item{align.at}{Where to align the sectors (see Details).} \item{max.span}{The angle of the maximal sector in radians. The default is to scale \samp{x} so that it sums to 2*pi.} \item{labels}{Labels placed around the sector arcs.} \item{labelpos}{Optional circumferential positions for the labels.} \item{label.radius}{How far away from the sectors the labels will be placed. May be a vector with a radius for each label.} \item{align}{Position of the alignment of sectors (see Details).} \item{shrink}{How much to shrink each successive sector in user units.} \item{main}{Optional title for the plot.} \item{ticks}{The number of ticks that would appear if the sectors were on a pie chart. Default is no ticks, TRUE gives the number of ticks equal to the integer sum of \samp{x}, which is fairly sensible if \samp{x} is a vector of integers.} \item{include.sumx}{Whether to include the sum of all \samp{x} values as the largest sector.} \item{...}{Additional arguments passed to \samp{polygon}.} } \details{ \samp{fan.plot} is now a call to fanPlot. } \value{ The circumferential positions of the labels in radians. These are returned in order of decreasing size of the values plotted. } \author{Jim Lemon, Anupam Tyagi} \keyword{misc} plotrix/man/emptyspace.Rd0000755000176000001440000000220111672104445015221 0ustar ripleyusers\name{emptyspace} \alias{emptyspace} \title{ Find an empty space on a plot } \description{ Try to find the largest empty rectangle on a plot. } \usage{ emptyspace(x,y=NULL) } \arguments{ \item{x,y}{x and y positions of the points on the plot.} } \details{ \samp{emptyspace} searches the pairs of points on the plot to find the largest rectangular space within which none of the points lie. It does not guarantee that the space will be large enough to fit a legend or text. Two alternatives are the \samp{largest.empty} function in the \pkg{Hmisc} package and the \samp{maxEmptyRect} function. While \samp{maxEmptyRect} will generally outperform \samp{emptyspace}, \samp{emptyspace} will sometimes find a slightly smaller, but "squarer" rectangle. } \value{ The \samp{x} and \samp{y} coordinates of the center of the rectangle found. } \author{Ray Brownrigg} \examples{ x<-rnorm(100) y<-rnorm(100) plot(x,y,main="Find the empty space",xlab="X",ylab="Y") es<-emptyspace(x,y) # use a transparent background so that any overplotted points are shown boxed.labels(es,labels="Here is the\nempty space",bg="transparent") } \keyword{misc} plotrix/man/ehplot.Rd0000644000176000001440000000422011561734264014347 0ustar ripleyusers\name{ehplot} \alias{ehplot} %- Also NEED an '\alias' for EACH other topic documented here. \title{ Engelmann-Hecker-Plot - EH-Plot } \description{ This R function provides a convenient way to visualize the distribution of grouped numerical data. } \usage{ ehplot(data, groups, intervals=50, offset=0.1, log=FALSE, median=TRUE, box=FALSE, boxborder="grey50", xlab="groups", ylab="values", col="black", ...) } \arguments{ \item{data}{ Vector of numerical data. } \item{groups}{ Vector of group names which should have the same length as data. } \item{intervals}{ The data is splitted into a certain number of intervals. If data points are in the same interval they are drawn side-by-side. } \item{offset}{ x-distance between two data points at the same interval. } \item{log}{ Logarithmic display } \item{median}{ To show the median of each group. NAs in data are not considered for calculating the medians. } \item{box}{ To underlay a boxplot. } \item{boxborder}{ The color of the boxplot if a boxplot is drawn. } \item{xlab}{ x-axis label } \item{ylab}{ y-axis label } \item{col}{ vector of colors for the datapoints. (recycled as necessary). } \item{\dots}{ additional plot-parameters will be passed to the plot-function } } \author{ Robby Engelmann and Michael Hecker } \seealso{\link{dendroPlot}} \examples{ data(iris) ehplot(iris$Sepal.Length, iris$Species, intervals=20, cex=1.8, pch=20) ehplot(iris$Sepal.Width, iris$Species, intervals=20, box=TRUE, median=FALSE) ehplot(iris$Petal.Length, iris$Species, pch=17, col="red", log=TRUE) ehplot(iris$Petal.Length, iris$Species, offset=0.06, pch=as.numeric(iris$Species)) # Groups don't have to be presorted: rnd <- sample(150) plen <- iris$Petal.Length[rnd] pwid <- abs(rnorm(150, 1.2)) spec <- iris$Species[rnd] ehplot(plen, spec, pch=19, cex=pwid, col=rainbow(3, alpha=0.6)[as.numeric(spec)]) } % Add one or more standard keywords, see file 'KEYWORDS' in the % R documentation directory. \keyword{ ~kwd1 } \keyword{ ~kwd2 }% __ONLY ONE__ keyword per line plotrix/man/drawSectorAnnulus.Rd0000644000176000001440000000127111631127311016525 0ustar ripleyusers\name{drawSectorAnnulus} \alias{drawSectorAnnulus} \title{Display a radial pie sector} \description{ Displays a radial pie sector with optional annuli. } \usage{ drawSectorAnnulus(angle1,angle2,radius1,radius2,col,angleinc=0.03) } \arguments{ \item{angle1,angle2}{Start and end angle for the sector.} \item{radius1,radius2}{Start and end of the radial extent of the annulus.} \item{col}{Color of the sector.} \item{angleinc}{The angular increment to use in drawing the arcs.} } \value{nil} \details{ \samp{drawSectorAnnulus} displays a single radial pie sector. It is probably only useful when called from \link{radial.pie}. } \author{Jim Lemon} \seealso{\link{radial.pie}} \keyword{misc} plotrix/man/drawNestedBars.Rd0000755000176000001440000000334212110347447015765 0ustar ripleyusers\name{drawNestedBars} \alias{drawNestedBars} \title{Display nested bars} \description{Displays the nested bars for barNest.} \usage{ drawNestedBars(x,start,end,shrink=0.1,errbars=FALSE,col=NA, labelcex=1,lineht=NA,showall=TRUE,barlabels=NULL,showlabels=TRUE, arrow.cap=NA) } \arguments{ \item{x}{One level of the breakdown produced by \samp{brkdnNest}.} \item{start,end}{The left and right x coordinates for the bar or group of bars to be displayed.} \item{shrink}{The proportion to shrink the width of the bars at each level.} \item{errbars}{Whether to display error bars on the bars.} \item{col}{The colors to use to fill the bars. See Details.} \item{labelcex}{Character size for the group labels.} \item{lineht}{The height of a margin line in user units.} \item{showall}{Whether to display the bars at any levels above the last.} \item{barlabels}{Optional labels to display below the bars.} \item{showlabels}{Whether to display the labels below the bars.} \item{arrow.cap}{The width of the "cap" on error bars in user units, defaulting to 0.01 of the width of the plot.} } \value{nil} \details{ \samp{drawNestedBars} displays the bars for the nested breakdown performed by \samp{brkdnNest}. It starts at the top of the list and calls itself for each level of the breakdown. It is unlikely to be useful for anything else. The combination of \samp{showlabels=TRUE} and \samp{showall=FALSE} allows the display of all of the labels below the plot with only the last set of bars being displayed. To have a set of labels not displayed, pass explicit \samp{barlabels} and have zero length labels for the level that is not to have labels. } \author{Jim Lemon and Ofir Levy} \seealso{\link{brkdnNest}, \link{drawNestedBars}} \keyword{misc} plotrix/man/draw.tilted.sector.Rd0000755000176000001440000000274311745225441016602 0ustar ripleyusers\name{draw.tilted.sector} \alias{draw.tilted.sector} \title{Display a 3D pie sector} \description{ Displays a 3D pie sector. } \usage{ draw.tilted.sector(x=0,y=0,edges=NA,radius=1,height=0.1,theta=pi/6, start=0,end=pi*2,border=par("fg"),col=par("bg"),explode=0,shade=0.8) } \arguments{ \item{x,y}{Position of the center of the pie sector in user units} \item{edges}{Number of edges to draw a complete ellipse} \item{radius}{the radius of the pie in user units} \item{height}{the height of the pie in user units} \item{theta}{The angle of viewing in radians} \item{start}{Starting angle of the sector} \item{end}{Ending angle of the sector} \item{border}{The color of the sector border lines} \item{col}{Color of the sector} \item{explode}{How far to "explode" the sectors in user units} \item{shade}{If > 0 and < 1, the proportion to reduce the brightness of the sector color to get a better 3D effect.} } \value{ The bisector of the pie sector in radians. } \details{ \samp{draw.tilted.sector} displays a single 3D pie sector. It is probably only useful when called from \link{pie3D}. The \samp{shade} argument proportionately reduces the brightness of the RGB color of the sector to produce a top lighted effect. If \samp{explode} is zero, only the top and outer side of each sector will be displayed. This will sometimes fix the problem of a pie with one huge sector greater than 3*pi/2 that cannot otherwise be drawn. } \author{Jim Lemon} \seealso{\link{pie3D}} \keyword{misc} plotrix/man/draw.radial.line.Rd0000644000176000001440000000431111762366377016204 0ustar ripleyusers\name{draw.radial.line} \alias{draw.radial.line} \title{Draw a radial line} \description{Draws a line radiating from a specified center, optionally expanding the line width as a function of distance from center.} \usage{ draw.radial.line(start, end, center=c(0, 0), angle=0, deg=NA, expand=FALSE, col=NA, lwd=NA, ...) } \arguments{ \item{start}{Distance from center of circular area to start of line in x/y user units.} \item{end}{Distance from center of circular area to end of line in x/y user units.} \item{center}{The center of the circular area in x/y user units.} \item{angle}{The angular position of the line in radians.} \item{deg}{The angular position of the line in degrees (takes precedence if not NA).} \item{expand}{TRUE to expand line width in proportion to distance from center.} \item{col}{The color of the line, NA for par("col").} \item{lwd}{The width of the line in device-specific units, NA for par("lwd").} \item{...}{Arguments passed to 'lines' (expand=FALSE) or 'polygon' (expand=TRUE).} } \value{nil} \details{ If the user passes a value for 'deg', this overrides any value passed to 'angle'. If 'expand' is FALSE, the line width is constant (as specified by par("lwd"). If 'expand' is TRUE, the line width is equal to the lwd value at distance 'end' and contracts as it moves towards 'start'. When expand is 'TRUE', lty is ignored. } \author{Ted Toal} \seealso{\link{lines}, link{draw.arc}} \examples{ plot(0, xlim=c(1,5), ylim=c(1,5), main="Test of radial lines", xlab="", ylab="", type="n") points(3, 3, pch=20) draw.radial.line(1, 2, center=c(3,3)) draw.radial.line(1, 2, center=c(3,3), angle=pi/4) draw.radial.line(1, 2, center=c(3,3), angle=pi/4+0.1, col="blue", lwd=4, lty=3) draw.radial.line(0.2, 1.2, center=c(3,3), deg=120, col="red", lwd=10) draw.radial.line(0.2, 1.2, center=c(3,3), deg=145, col="purple", lwd=10, lend=1) draw.radial.line(0.5, 2, center=c(3,3), deg=225, expand=TRUE, col="gold") draw.radial.line(0.7, 1.4, center=c(3,3), deg=180, expand=TRUE, col="orange", lwd=30) draw.radial.line(0.5, 1.5, center=c(3,3), deg=235, expand=TRUE, lwd=5, col="brown") draw.radial.line(0.1, 1.5, center=c(3,3), deg=325, expand=TRUE, lwd=5, col="green") } \keyword{misc} plotrix/man/draw.ellipse.Rd0000755000176000001440000000374012112006554015441 0ustar ripleyusers\name{draw.ellipse} \alias{draw.ellipse} \title{Draw ellipse} \description{Draws ellipses on an existing plot.} \usage{ draw.ellipse(x, y, a = 1, b = 1, angle = 0, segment = c(0, 360), arc.only = TRUE, deg = TRUE, nv = 100, border = NULL, col = NA, lty = 1, lwd = 1, ...) } \arguments{ \item{x}{ A vector or a matrix (if \code{y} is missing).} \item{y}{ A vector, can be missing. } \item{a,b}{ Vectors, radii of the ellypses along the two axes in user units. } \item{angle}{ Angle of rotation in degrees (if \code{deg=TRUE}) or in radians (if \code{deg=FALSE}). } \item{segment}{ Start and endpoints of arc in degrees (if \code{deg=TRUE}) or in radians (if \code{deg=FALSE}). } \item{arc.only}{ Logical, if \code{segmen} the full ellipse is not drawn, radii from the ends of the arc are drawn to form a sector (see Examples). } \item{deg}{ Logical, if angles are given in degrees (\code{TRUE}) or radians. } \item{nv}{ Number of vertices to draw the ellipses. } \item{border}{ Color to use for drawing the circumference. } \item{col}{ Color to use for filling the circle. } \item{lty}{ Line type for the circumference. } \item{lwd}{ Line width for the circumference. } \item{\dots}{ Additional arguments passed to \code{\link{polygon}}. } } \value{Draw ellipses as a side effect.} \author{Peter Solymos } \seealso{\link{polygon}} \examples{ plot(c(0,10), c(0,10), type="n", main="test draw.ellipse") draw.ellipse(c(3,7), c(8,8), c(0.5,1), c(1,0.5), col=c(2,4), angle=c(45,0), segment=rbind(c(0,45),c(45,360))) draw.ellipse(c(3,7), c(6,6), c(0.5,1), c(1,0.5), col=c(2,4), angle=c(45,0), segment=rbind(c(0,45),c(45,360)), arc.only=FALSE) draw.ellipse(c(3,7), c(4,4), c(0.5,1), c(1,0.5), border=c(2,4), angle=c(45,0), segment=rbind(c(0,45),c(45,360)), arc.only=FALSE) draw.ellipse(c(3,7), c(2,2), c(0.5,1), c(1,0.5), border=1, angle=c(45,0), lty=3) draw.ellipse(c(3,7), c(2,2), c(0.5,1), c(1,0.5), border=c(5,3), angle=c(45,0), nv=c(3,4), lty=2, lwd=2) } \keyword{misc} plotrix/man/draw.circle.Rd0000755000176000001440000000232012112003602015225 0ustar ripleyusers\name{draw.circle} \alias{draw.circle} \title{Draw a circle} \description{Draws a circle on an existing plot.} \usage{ draw.circle(x,y,radius,nv=100,border=NULL,col=NA,lty=1,lwd=1) } \arguments{ \item{x,y}{Coordinates of the center of the circle.} \item{radius}{Radius (or radii) of the circle(s) in user units.} \item{nv}{Number of vertices to draw the circle.} \item{border}{Color to use for drawing the circumference.} \item{col}{Color to use for filling the circle.} \item{lty}{Line type for the circumference.} \item{lwd}{Line width for the circumference.} } \value{ A list with the x and y coordinates of the points on the circumference of the last circle displayed. } \details{ \samp{draw.circle} uses the dimensions of the plot and the \samp{x} and \samp{y} coordinates to draw a circle rather than an ellipse. } \author{Jim Lemon} \seealso{\link{polygon}} \examples{ plot(1:5,seq(1,10,length=5),type="n",xlab="",ylab="",main="Test draw.circle") draw.circle(2,4,c(1,0.66,0.33),border="purple", col=c("#ff00ff","#ff77ff","#ffccff"),lty=1,lwd=1) draw.circle(2.5,8,0.6,border="red",lty=3,lwd=3) draw.circle(4,3,0.7,border="green",lty=1,lwd=1) draw.circle(3.5,7,0.8,border="blue",lty=2,lwd=2)} \keyword{misc} plotrix/man/draw.arc.Rd0000755000176000001440000000410611762341425014557 0ustar ripleyusers\name{draw.arc} \alias{draw.arc} \title{ Draw arc } \description{ Draw one or more arcs using classic graphics. } \usage{ draw.arc(x=1,y=NULL,radius=1,angle1=deg1*pi/180,angle2=deg2*pi/180, deg1=0,deg2=45,n=0.05,col=NA,lwd=NA,...) } \arguments{ \item{x}{ x coordinate of center. Scalar or vector. } \item{y}{ y coordinate of center. Scalar or vector. } \item{radius}{ radius. Scalar or vector. } \item{angle1}{ Starting angle in radians. Scalar or vector. } \item{angle2}{ Ending angle in radians. Scalar or vector. } \item{deg1}{ Starting angle in degrees. Scalar or vector. } \item{deg2}{ Ending angle in degrees. Scalar or vector. } \item{n}{ Number of polygons to use to approximate the arc. } \item{col}{ Arc colors. } \item{lwd}{Line width for the arc.} \item{...}{ Other arguments passed to segments. Vectorization is not supported for these. } } \details{ Draws one or more arcs from \code{angle1} to \code{angle2}. If \code{angle1} is numerically greater than \code{angle2}, then the angles are swapped. Be sure to use an aspect ratio of 1 as shown in the example to avoid distortion. For argument 'n' (which may be either a scalar or a vector, although most likely you will leave it at the default value), an integer value means to use that number of segments to approximate the arc, while a non-integer value means to use enough segments so that the angle that successive segments make with one another is no more than n radians. } \value{ Returns a matrix of expanded arguments invisibly. } \author{Gabor Grothendieck. Improvements by Ted Toal.} \examples{ plot(1:10, asp = 1,main="Test draw.arc") draw.arc(5, 5, 1:10/10, deg2 = 1:10*10, col = "blue") draw.arc(8, 8, 1:10/10, deg2 = 1:10*10, col = 1:10) draw.arc(5, 5, 3, deg1=100, deg2=170, col="gold", lwd=50, lend=1) # example taken from post by Hans Borcher: # https://stat.ethz.ch/pipermail/r-help/2009-July/205728.html # Note setting of aspect ratio to 1 first. curve(sin(x), 0, pi, col="blue", asp=1) draw.arc(pi/2, 0, 1, deg1=45, deg2=135, col="red") } \keyword{misc} plotrix/man/dotplot.mtb.Rd0000755000176000001440000000404611334501304015314 0ustar ripleyusers\name{dotplot.mtb} \alias{dotplot.mtb} \title{ Minitab style dotplots } \description{ Create a dotplot of a data vector in the sense of ``dotplot'' as used in the Minitab\eqn{\mbox{\copyright}}{\ (copyright)} package. } \usage{ dotplot.mtb(x, xlim = NULL, main = NULL, xlab = NULL, ylab = NULL, pch = 19, hist = FALSE, yaxis = FALSE, mtbstyle=TRUE) } \arguments{ \item{x}{ A numeric vector. } \item{xlim}{ The x limits of the plot. } \item{main}{ A title for the plot; defaults to blank.} \item{xlab}{ A label for the x axis; defaults to blank.} \item{ylab}{ A label for the y axis; defaults to blank.} \item{pch}{ The plotting symbol for the dots in the plot; defaults to a solid disc. } \item{hist}{ Logical scalar; should the plot be done ``histogram style, i.e. using vertical lines rather than stacks of dots?} \item{yaxis}{ Logical scalar; should a y-axis be produced? } \item{mtbstyle}{ Logical scalar; should the dotplot be done in the ``Minitab'' style? I.e. should the zero level be at the vertical midway point? } } \details{ The result of \code{hist=TRUE} looks less ugly than stacks of dots for very large data sets. } \value{ Nothing. A plot is produced as a side effect. } \author{ Barry Rowlingson \email{B.Rowlingson@lancaster.ac.uk} and Rolf Turner \email{r.turner@auckland.ac.nz} } \section{Warnings}{ This function does something toadally different from the \code{dotplot()} (now \code{\link{dotchart}()}) function in the graphics package. The labelling of the \code{y}-axis is device dependent. } \examples{ \dontrun{ set.seed(42) x <- rpois(100,10) dotplot.mtb(x,main="No y-axis.") dotplot.mtb(x,yaxis=TRUE,main="With y-axis displayed.") dotplot.mtb(x,hist=TRUE,main="An \"h\" style plot.") dotplot.mtb(x,xlim=c(4,16),main="With the x-axis limited.") dotplot.mtb(x,yaxis=TRUE,mtbstyle=FALSE,main="Non-Minitab style.") dotplot.mtb(x,yaxis=TRUE,xlab="x",ylab="count", main="With x and y axis labels.") } } \keyword{ hplot } plotrix/man/dispersion.Rd0000755000176000001440000000615011704224746015240 0ustar ripleyusers\name{dispersion} \alias{dispersion} \alias{dispbars} \title{ Display a measure of dispersion } \description{ Display line/cap bars at specified points on a plot representing measures of dispersion. } \usage{ dispersion(x,y,ulim,llim=ulim,intervals=TRUE,arrow.cap=0.01,arrow.gap=NA, type="a",fill=NA,lty=NA,pch=NA,border=NA,display.na=TRUE,...) } \arguments{ \item{x,y}{x and y position of the centers of the bars} \item{ulim,llim}{The extent of the dispersion measures.} \item{arrow.cap}{The width of the cap at the outer end of each bar as a proportion of the width of the plot.} \item{arrow.gap}{The gap to leave at the inner end of each bar. Defaults to two thirds of the height of a capital "O".} \item{intervals}{Whether the limits are intervals (TRUE) or absolute values (FALSE).} \item{type}{What type of display to use.} \item{fill}{Color to fill between the lines if \samp{type} is not NULL and \samp{fill} is not NA.} \item{lty}{Line type for redrawing the lines if necessary.} \item{pch}{Symbol for redrawing the points if necessary.} \item{border}{Line type for drawing a border on the confidence band.} \item{display.na}{Whether to display NA values as lines going off the plot.} \item{...}{additional arguments passed to \samp{arrows} or \samp{lines} depending upon \samp{type}.} } \details{ \samp{dispersion} displays a measure of dispersion on an existing plot. Currently it will display either vertical lines with caps (error bars) or lines that form a "confidence band" around a line of central tendency. If \samp{fill} is not NA and \samp{type} is \samp{"l"}, a polygon will be drawn between the confidence lines. Remember that any points or lines within the confidence band will be obscured, so pass point and/or line types as in the second example. The default behavior is to display an undefined dispersion (e.g. a variance with only one observation) as a line going off the plot. If \samp{display.na} is FALSE, NA values will not be displayed, allowing the user to show only upper or lower dispersion limits. The \samp{intervals} argument allows the user to pass the limits as either intervals (the default) or absolute values. If \samp{arrow.gap} is greater than or equal to the upper or lower limit for a bar, \samp{segments} is used to draw the upper and lower caps with no bars to avoid zero length arrows. } \value{nil} \author{Jim Lemon} \seealso{\link{arrows}, \link{segments},\link{lines}} \examples{ disptest<-matrix(rnorm(200),nrow=20) disptest.means<-rowMeans(disptest) row.order<-order(disptest.means) se.disptest<-unlist(apply(disptest,1,std.error)) plot(disptest.means[row.order],main="Dispersion as error bars", ylim=c(min(disptest.means-se.disptest),max(disptest.means+se.disptest)), xlab="Occasion",ylab="Value") dispersion(1:20,disptest.means[row.order],se.disptest[row.order]) plot(disptest.means[row.order],main="Dispersion as confidence band", ylim=c(min(disptest.means-se.disptest),max(disptest.means+se.disptest)), xlab="Occasion",ylab="Value") dispersion(1:20,disptest.means[row.order],se.disptest[row.order],type="l", fill="#eeccee",lty=2,pch=1) } \keyword{misc} plotrix/man/diamondplot.Rd0000755000176000001440000000176611334501264015373 0ustar ripleyusers\name{diamondplot} \alias{diamondplot} \title{Plot multiple variables as polygons on a radial grid} \usage{ diamondplot(x, bg=gray(0.6), col=rainbow,name="", ...) } \arguments{ \item{x}{A data frame containing numeric values that represent attributes (possibly repeated observations) of data objects. See the example.} \item{bg}{The background color for the plot.} \item{col}{The colors for the polygons.} \item{name}{The title for the plot (i.e. \samp{main}).} \item{...}{additional arguments passed to \samp{plot}.} } \description{ \samp{diamondplot} displays a plot of polygons on a radial grid representing the relationships between one or more attributes of data objects. For a slightly different style of plot, see the "spiderweb plot" example in \samp{radial.plot}. } \value{nil} \author{Elisa Biancotto} \keyword{misc} \seealso{\link{plot}, \link{radial.plot}} \examples{ data(mtcars) mysubset<-mtcars[substr(dimnames(mtcars)[[1]],1,1)=="M",c("mpg","hp","wt","disp")] diamondplot(mysubset) } plotrix/man/dendroPlot.Rd0000644000176000001440000000617611754142561015177 0ustar ripleyusers\name{dendroPlot} \alias{dendroPlot} \title{ Display distributions as dendrites } \description{ Display the distributions of one or more sets of points as branching (dendritic) clusters. } \usage{ dendroPlot(x,breaks=list(10,10,10),pch=1,col=par("fg"),cex=1,nudge=NA, setlabels=NA,...) } \arguments{ \item{x}{A list or data frame of numeric or factor or character columns.} \item{breaks}{A list of cutpoints to transform numeric values into factors (see \link{cut}). Must be at least one number >= 2.} \item{pch}{Symbol(s) to use in plotting the values.} \item{col}{Color(s) for the symbols.} \item{cex}{Size of the symbol(s) to use in plotting.} \item{nudge}{The amount to set each consecutive value in a category away from the center of the dendrite.} \item{setlabels}{Labels to place along the abcissa to identify the sets.} \item{...}{Other arguments passed to plot.} } \details{ \samp{dendroPlot} displays the distributions of categorical values as stacks of "branches". The lengths of the branches show the number of values in each category, rather like the opposed bars in a pyramid plot, except that there is no separation of groups. The distribution of numeric values can also be displayed by passing a set of breakpoints to categorize the values. The breakpoints will usually be equidistant, but unevenly spaced breakpoints can be passed. If an element of \samp{x} is numeric, the values of the corresponding \samp{x} element will be used to place the points, but the branches will be defined as the categories formed by applying the breaks to those numeric values. Note that in the first example, the breakpoints for the first and third elements are used to define the ten branches for each. The second element of \samp{x} is already categorical, so the breakpoints are ignored. When comparing distributions with very different ranges it may be necessary to adjust the breakpoints to get a satisfactory result. Each successive point in a category is \samp{nudge}d away from the center of the dendrite. If \samp{nudge} has more than one value, the points will be nudged up and down for categorical variables to enable closer packing. The second value of \samp{nudge} is ignored for numeric variables. The aspect ratio of the plot, the character expansion and the nudging will have to be adjusted to give the best point spacing for most dendroPlots. } \note{The \samp{ehplot} function is a much more versatile instantiation of this type of plot. \samp{dendroPlot} has been retained as there are currently a few differences that some users may find valuable. However, it is not impossible that \samp{dendroPlot} will disappear in the future. Another very useful version of this type of plot is \samp{beeswarm} in the \pkg{beeswarm} package. } \value{nil} \author{Jim Lemon} \seealso{\link{ehplot}} \examples{ x<-list(runif(90,1,3),factor(sample(LETTERS[1:10],100,TRUE)),rnorm(80,mean=5)) dendroPlot(x,xlab="Groups",ylab="Value of x",main="Test dendroPlot I") # now apply a nudge factor and different breaks dendroPlot(x,breaks=list(8,10,10),nudge=c(0.05,0.1), xlab="Groups",ylab="Value of x",main="Test dendroPlot II") } \keyword{misc} plotrix/man/death_reg.Rd0000644000176000001440000000034411661157615015001 0ustar ripleyusers\name{death_reg} \alias{death_reg} \title{Death registrations from 1996 to 2010} \description{ Death registrations for underlying cause of death as ICD-10 chapters for 1996 to 2010. } \usage{ data(death_reg) } \keyword{misc} plotrix/man/cylindrect.Rd0000755000176000001440000000327011334501252015206 0ustar ripleyusers\name{cylindrect} \alias{cylindrect} \title{Display an apparent cylinder} \description{Display rectangles shaded to appear like cylinders.} \usage{ cylindrect(xleft,ybottom,xright,ytop,col,border=NA,gradient="x",nslices=50) } \arguments{ \item{xleft}{The position of the left side of the rectangle(s).} \item{ybottom}{The position of the bottom of the rectangle(s).} \item{xright}{The position of the right side of the rectangle(s).} \item{ytop}{The position of the top side of the rectangle(s).} \item{col}{The base color(s) of the rectangles.} \item{border}{Whether to draw a border and what color.} \item{gradient}{Whether to vary the shading horizontally ("x" - the default) or vertically (anything but "x").} \item{nslices}{The number of "slices" of color for shading.} } \value{The base color(s) of the rectangle(s).} \details{ \samp{cylindrect} displays a rectangle filled with "slices" of color that simulate the appearance of a cylinder. The slices are calculated so that the base color appears at the right or bottom edge of the rectangle, becomes progressively lighter to a "highlight" at two thirds of the width or height and then darkens toward the base color again. The appearance is of a cylinder lit from above and to the left of the viewer. The position of the apparent light source is hard coded into the function. } \author{Jim Lemon} \seealso{\link{gradient.rect}} \examples{ plot(0,xlim=c(0,5),ylim=c(0,5),main="Examples of pseudocylindrical rectangles", xlab="",ylab="",axes=FALSE,type="n") cylindrect(0,0,1,5,"red") cylindrect(rep(1,3),c(0,2,4),rep(4,3),c(1,3,5),"green",gradient="y") cylindrect(4,0,5,5,"#8844aa") } \keyword{misc} plotrix/man/count.overplot.Rd0000755000176000001440000000214111324072574016054 0ustar ripleyusers\name{count.overplot} \alias{count.overplot} \title{Show overlying points as counts} \usage{ count.overplot(x,y,tol=NULL,col=par("fg"),pch="1",...) } \arguments{ \item{x,y}{Two numeric data vectors or the first two columns of a matrix or data frame. Typically the x/y coordinates of points to be plotted.} \item{tol}{The largest distance between points that will be considered to be overlying.} \item{col}{Color(s) for the points (not the numbers).} \item{pch}{Symbol(s) to display.} \item{...}{additional arguments passed to \samp{plot}.} } \description{ \samp{count.overplot} checks for overlying points defined as points separated by a maximum of \samp{tol}, a two element numeric vector of the x and y tolerance. Defaults to 1/2 of the width of a lower case "o" in the x direction and 1/2 of the height of a lower case "o" in the y direction. } \value{nil} \keyword{misc} \author{Jim Lemon} \seealso{\link{cluster.overplot},\link{sizeplot}} \examples{ xy.mat<-cbind(sample(1:10,200,TRUE),sample(1:10,200,TRUE)) count.overplot(xy.mat,main="count.overplot", xlab="X values",ylab="Y values") } plotrix/man/corner.label.Rd0000755000176000001440000000261111154422354015417 0ustar ripleyusers\name{corner.label} \alias{corner.label} \title{Find corner locations and optionally display a label} \description{ Finds the coordinates in user parameters of a specified corner of the figure region and optionally displays a label there } \usage{ corner.label(label=NULL,x=-1,y=1,xoff=NA,yoff=NA,figcorner=FALSE,...) } \arguments{ \item{label}{Text to display. The default is to display nothing.} \item{x}{an integer value: -1 for the left side of the plot, 1 for the right side} \item{y}{an integer value: -1 for the bottom side of the plot, 1 for the top side} \item{xoff,yoff}{Horizontal and vertical text offsets. Defaults to one half of the width and height of "m" respectively. } \item{figcorner}{Whether to find/display at the corner of the plot or figure.} \item{...}{further arguments to the \samp{text} command for the label} } \details{ \samp{corner.label} finds the specified corner of the plot or figure and if \samp{label} is not NULL, displays it there. The text justification is specified so that the label will be justified away from the corner. To get the label squeezed right into a corner, set \samp{xoff} and \samp{yoff} to zero. } \value{ A list of the x and y positions of the corner adjusted for the offsets. } \author{Ben Bolker} \examples{ plot(1:10,1:10) corner.label("A") corner.label(x=1,y=1) corner.label("B",y=-1,x=1,figcorner=TRUE,col="red") } \keyword{aplot} plotrix/man/color2D.matplot.Rd0000755000176000001440000001433511672103167016045 0ustar ripleyusers\name{color2D.matplot} \alias{color2D.matplot} \title{Display a numeric matrix as color matrix} \description{ Display the values of a numeric 2D matrix or data frame as colored rectangles or hexagons. } \usage{ color2D.matplot(x,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1), extremes=NA,cellcolors=NA,show.legend=FALSE,nslices=10,xlab="Column", ylab="Row",do.hex=FALSE,axes=TRUE,show.values=FALSE,vcol=NA,vcex=1, border="black",na.color=NA,xrange=NULL,color.spec="rgb",yrev=TRUE, xat=NULL,yat=NULL,Hinton=FALSE,...) } \arguments{ \item{x}{data values} \item{cs1,cs2,cs3}{the color parameters that will be scaled to represent the range of numeric values. (see \samp{color.scale})} \item{extremes}{The colors for the extreme values of \samp{x}. Takes precedence over the color ranges.} \item{cellcolors}{A precalculated matrix of cell colors. This must have the same number of rows and columns as the matrix or it will be uninformative. It can be a vector, but be careTakes precedence over both \samp{extremes} and color ranges.} \item{show.legend}{whether to display a color legend with the extreme numeric values in the lower left corner of the plot. This will force the color specification to "rgb", so if this is different from the color specification requested, call \samp{color.legend} separately.} \item{nslices}{The number of color "slices" in the legend.} \item{xlab,ylab}{axis labels for the plot.} \item{do.hex}{plot packed hexagons instead of rectangles.} \item{axes}{Whether to suppress the default axis labelling.} \item{show.values}{Whether to display the numeric values of \samp{x}. This also controls the number of decimal places displayed.} \item{vcol}{The color for the value display. If NA, the values are displayed in black or white depending upon the darkness of the cell color.} \item{vcex}{The character expansion for the value display.} \item{border}{The color(s) for the borders of the cells. Pass NA if no border is wanted.} \item{na.color}{The color to use for NA values of \samp{x}.} \item{xrange}{An explicit range for the transformation of colors. see \samp{color.scale}} \item{color.spec}{The color specification system to use.} \item{yrev}{Whether to reverse the order of the y-axis to display the cells in "reading" order (left to right and top to bottom) if TRUE, or in the order of a typical plot (left to right and bottom to top) if FALSE.} \item{xat,yat}{Values at which to place tick marks to override \samp{pretty}.} \item{Hinton}{Whether to display a Hinton diagram in which the magnitude of cell values is proportional to the size of the squares and the sign is indicated by the color of the squares.} \item{...}{arguments passed to \samp{plot}.} } \value{nil} \details{ Displays a plot with the same number of rectangular or hexagonal cells as there are numeric values in the matrix or data frame. Each rectangle is colored to represent its corresponding value. The rectangles are arranged in the conventional display of a 2D matrix with rows beginning at the top and columns at the left. To get the rows beginning at the bottom, use \samp{yrev=FALSE}. The color scale defaults to black for the minimum value and white for the maximum. The user will have to adjust the plot device dimensions to get regular squares or hexagons, especially when the matrix is not square. As the margins are not equivalent for all display devices, this is currently a matter of trial and error. Drawing hexagons is quite slow. \samp{show.values} and \samp{show.legend} are also used to control the number of decimal places displayed if the values or legend are shown. \samp{TRUE} will give one decimal place, \samp{2} two, and so on. if \samp{Hinton} is TRUE, a Hinton diagram in which the sizes of the squares are proportional to the absolute value of \samp{x} and the colors of the squares indicate the sign of the \samp{x} values will be displayed. This only works with squares. } \note{ The function \link{image} performs almost the same when passed a matrix of values without grid positions, except that it assigns values to a specified list of colors rather than calculating a color for each distinct value. } \author{Jim Lemon (thanks to Ashoka Polpitiya for \samp{axes})} \seealso{\link{color.scale}, \link{image}} \examples{ x<-matrix(rnorm(1024),nrow=32) # simulate a correlation matrix with values -0.5 to 0.5 x<-rescale(x,c(-0.5,0.5)) # add a column with the extreme values (-1,1) to calculate # the colors, then drop the extra column in the result cellcol<-color.scale(cbind(x,c(-1,rep(1,31))),c(0,1),0,c(1,0))[,1:32] color2D.matplot(x,cellcolors=cellcol,main="Blue to red correlations") # do the legend call separately to get the full range color.legend(0,-5,6.5,-3,legend=c(-1,-0.5,0,0.5,1), rect.col=color.scale(c(-1,-0.5,0,0.5,1),c(0,1),0,c(1,0)),align="rb") x<-matrix(rnorm(100),nrow=10) # generate colors that show negative values in red to brown # and positive in blue-green to green cellcol<-matrix(rep("#000000",100),nrow=10) cellcol[x<0]<-color.scale(x[x<0],c(1,0.8),c(0,0.8),0) cellcol[x>0]<-color.scale(x[x>0],0,c(0.8,1),c(0.8,0)) # now do hexagons without borders color2D.matplot(x,cellcolors=cellcol,xlab="Columns",ylab="Rows", do.hex=TRUE,main="2D matrix plot (hexagons)",border=NA) # for this one, we have to do the color legend separately # because of the two part color scaling legval<-seq(min(x),max(x),length.out=6) legcol<-rep("#000000",6) legcol[legval<0]<-color.scale(legval[legval<0],c(1,0.8),c(0,0.8),0) legcol[legval>0]<-color.scale(legval[legval>0],0,c(0.8,1),c(0.8,0)) color.legend(0,-1.8,3,-1.4,round(c(min(x),0,max(x)),1),rect.col=legcol) # do a color only association plot xt<-table(sample(1:10,100,TRUE),sample(1:10,100,TRUE)) observed<-xt[,rev(1:dim(xt)[2])] expected<-outer(rowSums(observed),colSums(observed),"*")/sum(xt) deviates<-(observed-expected)/sqrt(expected) cellcol<-matrix(rep("#000000",100),nrow=10) cellcol[deviates<0]<- color.scale(deviates[deviates<0],c(1,0.8),c(0,0.5),0) cellcol[deviates>0]<- color.scale(deviates[deviates>0],0,c(0.7,0.8),c(0.5,0)) color2D.matplot(x=round(deviates,2),cellcolors=cellcol, show.values=TRUE,main="Association plot") color2D.matplot(x,extremes=c(2,3),main="Hinton diagram (green +, red -)", Hinton=TRUE) } \keyword{misc} plotrix/man/color.scale.lines.Rd0000755000176000001440000000442312045714230016366 0ustar ripleyusers\name{color.scale.lines} \alias{color.scale.lines} \title{Line segments with scaled colors} \description{Display line segments with colors scaled to numeric values.} \usage{ color.scale.lines(x,y,reds,greens,blues,col=NA,colvar=NA,...) } \arguments{ \item{x,y}{Numeric vectors or a list with at least two components, the first two of which must be named x and y.} \item{reds,greens,blues}{Color ranges into which to scale the numeric values.} \item{col}{One or more colors to use for the resultant lines. Will be recycled if necessary.} \item{colvar}{A numeric vector from which to scale the colors.} \item{...}{Additional arguments passed to \samp{segments}.} } \details{ \samp{color.scale.lines} displays line segments that can be individually colored according to a variety of methods. In order of precedence, if \samp{col} is not NA, the color values passed will be used. If \samp{colvar} is not NA, the function will call \samp{color.scale} with the three color range arguments to determine the line colors. If \samp{colvar} is the same length as \samp{length(x)-1}, exactly enough colors for the number of lines displayed will be calculated. If shorter, some colors will be recycled and if longer, some colors will not be used. Finally, the values in \samp{y} will be color-scaled if both of the above arguments are NA. Thus the user can pass predetermined colors, use colors scaled from an arbitrary vector of numerical values or use the \samp{y} values. See \samp{color.scale} for an explanation of specifying color ranges. } \note{ The function is useful for highlighting a numeric dimension or adding an extra "dimension" to a plot. } \value{nil} \author{Jim Lemon} \seealso{\link{color.scale}} \examples{ # color a random walk "hot" (red) to "cold" (blue) on its distance # from the starting point x<-c(0,cumsum(rnorm(99))) y<-c(0,cumsum(rnorm(99))) xydist<-sqrt(x*x+y*y) plot(x,y,main="Random walk plot",xlab="X",ylab="Y",type="n") color.scale.lines(x,y,c(1,1,0),0,c(0,1,1),colvar=xydist,lwd=2) boxed.labels(x,y,labels=1:100,border=FALSE,cex=0.5) # now color the lines to show whether each step went away from # or toward the starting position color.scale.lines(x,y,col=2+(diff(xydist)>0)) boxed.labels(x,y,labels=1:100,border=FALSE,cex=0.5) } \keyword{misc} plotrix/man/color.scale.Rd0000755000176000001440000000765111556515270015274 0ustar ripleyusers\name{color.scale} \alias{color.scale} \title{Turn values into colors.} \description{Transform numeric values into colors using RGB, HSV or HCL} \usage{ color.scale(x,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1),alpha=1, extremes=NA,na.color=NA,xrange=NULL,color.spec="rgb") } \arguments{ \item{x}{a numeric vector, matrix or data frame} \item{cs1,cs2,cs3}{color parameters for scaling \samp{x}} \item{alpha}{Value for transparency in colors.} \item{extremes}{The colors for the extreme values of \samp{x} (RGB only).} \item{na.color}{The color to use for NA values of \samp{x}.} \item{xrange}{An explicit range to use in the transformation.} \item{color.spec}{The color specification to use in the transformation. Anything other than "rgb", "hsv" or "hcl" will almost certainly fail.} } \details{ \samp{color.scale} calculates a sequence of colors by a linear transformation of the numeric values supplied into the ranges for the three color parameters. If only one number is supplied for a color range, that color remains constant for all values of \samp{x}. If more than two values are supplied, the \samp{x} values will be split into equal ranges (one less than the number of colors) and the transformation carried out on each range. Values for a color range must be between 0 and 1 for the RGB or HSV specifications, and between 0 and 360 (cs1) and 0 to 100 (cs2 and cs3) for the HCL specifications. IMPORTANT: If \samp{x} has fewer values than the number of values in the color parameters, it will usually return incorrect colors. This is usually only a problem when using \samp{color.legend} with a small number of rectangles in the legend as \samp{color.legend} calls \samp{color.scale} to calculate the color rectangles. If \samp{extremes} is not NA, the ranges will be calculated from its values using \samp{col2rgb}, even if ranges are also supplied. \samp{extremes} allows the user to just pass the extreme color values in any format that \samp{col2rgb} will accept. Note that this forces the color specification to RGB. If the user wants to specify a range of values with \samp{xrange}, it must at least include the range of x values. This can be useful when there is a notional range like 0-100% that the values do not cover, or when several series of values with different ranges are to be assigned the same color scale. The user may not want the color scheme to be continuous across some critical point, often zero. In this case, color scale can be called separately for the values below and above zero. I may get around to adding an argument to do this in one shot. Until then, see the second example for \samp{color2D.matplot} and also the \samp{diverge.hcl} and \samp{diverge.hsv} functions in the \samp{colorspace} package. } \note{ The function is useful for highlighting a numeric dimension or adding an extra "dimension" to a plot. There are quite a few R functions that transform numeric values into colors or produce colors that can be used to represent values. Two packages that might be of interest are \pkg{RColorBrewer} and \pkg{colourschemes}. } \value{A vector or matrix of hexadecimal color values.} \author{Jim Lemon} \seealso{\link{rescale}, \link{col2rgb}, \link{smoothColors}} \examples{ # go from green through yellow to red with no blue x<-rnorm(20) y<-rnorm(20) # use y for the color scale plot(x,y,col=color.scale(y,c(0,1,1),c(1,1,0),0),main="Color scale plot", pch=16,cex=2) plot(1:10,rep(1:3,length.out=10),axes=FALSE,type="n",xlim=c(0,11),ylim=c(0,4), main="Test of RGB, HSV and HCL",xlab="",ylab="Color specification") axis(2,at=1:3,labels=c("HCL","HSV","RGB")) points(1:10,rep(1,10),pch=19,cex=8,col=color.scale(1:10,c(0,300),35,85, color.spec="hcl")) points(1:10,rep(2,10),pch=19,cex=8,col=color.scale(1:10,c(0,1), 0.8,1,color.spec="hsv")) points(1:10,rep(3,10),pch=19,cex=8,col=color.scale(1:10,c(1,0.5,0), c(0,0.5,0),c(0,0,1),color.spec="rgb")) } \keyword{misc} plotrix/man/color.legend.Rd0000755000176000001440000000603311516247666015443 0ustar ripleyusers\name{color.legend} \alias{color.legend} \title{Legend matching categories or values to colors} \description{Display a color legend on a plot} \usage{ color.legend(xl,yb,xr,yt,legend,rect.col,cex=1,align="lt",gradient="x",...) } \arguments{ \item{xl,yb,xr,yt}{The lower left and upper right coordinates of the rectange of colors in user coordinates.} \item{legend}{The labels that will appear next to some or all of the colors.} \item{rect.col}{The colors that will fill the rectangle.} \item{cex}{Character expansion factor for the labels.} \item{align}{How to align the labels relative to the color rectangle.} \item{gradient}{Whether to have a horizontal (x) or vertical (y) color gradient.} \item{...}{Additional arguments passed to \samp{text}.} } \value{nil} \details{ \samp{color.legend} displays a rectangle defined by the first four arguments filled with smaller rectangles of color defined by the \samp{rect.col} argument. Labels, defined by the \samp{legend} argument, are placed next to the color rectangle. The position of the labels is determined by whether the color rectangle is horizontal or vertical and the \samp{align} argument. The default value of \samp{lt} places the labels at the left of a vertical rectangle or the top of a horizontal one. \samp{rb} puts them on the other side. To have the labels in the same color as the rectangles, include a \samp{col} argument that will be passed to \samp{text} as in the example. There can be fewer labels than colors. The labels will be evenly spaced along the rectangle in this case. It is possible to use empty labels to get uneven spacing. The user can pass more labels than colors, but the labels will almost certainly be crowded and I have only found one use for this. If the user wants the labels at the intersection of the boxes rather than in the center, see the alternative specification for the labels in the example (thanks Claudia Tebaldi). To have complete control over the labels, see \link{gradient.rect} and \link{text} or \link{mtext}. samp{colorlegend} in the \pkg{shape} package offers a different approach, creating a large number of colors from a color generating function (a bit like \samp{color.gradient}) and then allowing the user to specify tick marks at arbitrary points along the color bar. } \author{Jim Lemon} \seealso{\link{color.gradient}, \link{gradient.rect}} \examples{ # get some extra room par(mar=c(7,4,4,6)) testcol<-color.gradient(c(0,1),0,c(1,0),nslices=5) col.labels<-c("Cold","Warm","Hot") # this will put the labels at the intersections # col.labels<-c("","Cold","","Warm","","Warmer","","Hot","") color2D.matplot(matrix(rnorm(100),nrow=10),c(1,0),0,c(0,1), main="Test color legends") color.legend(11,6,11.8,9,col.labels,testcol,gradient="y") color.legend(10.2,2,11,5,col.labels,testcol,align="rb",gradient="y") color.legend(0.5,-2,3.5,-1.2,col.labels,testcol) color.legend(7,-1.8,10,-1,col.labels,testcol,align="rb",col=testcol[c(1,3,5)]) par(mar=c(5,4,4,2)) } \keyword{misc} plotrix/man/color.id.Rd0000755000176000001440000000076611324071740014571 0ustar ripleyusers\name{color.id} \alias{color.id} \title{Identify closest match to a color} \description{ Given a color given as a hex string, find the closest match in the table of known (named) colors } \usage{ color.id(col) } \arguments{ \item{col}{a color specified as a hex string} } \details{ finds the color with the minimum squared distance in RGB space } \value{ the name of the closest match } \author{Ben Bolker} \seealso{\link{col2rgb},\link{colors}} \examples{ color.id("#cc00cc") } \keyword{color} plotrix/man/color.gradient.Rd0000755000176000001440000000211311334501130015746 0ustar ripleyusers\name{color.gradient} \title{Calculate an arbitrary sequence of colors} \usage{ color.gradient(reds,greens,blues,nslices=50) } \alias{color.gradient} \arguments{ \item{reds,greens,blues}{vectors of the values of the color components as 0 to 1.} \item{nslices}{The number of color "slices".} } \description{ \samp{color.gradient} is now just a call to \samp{color.scale} with a vector of equally spaced integers (1:nslices). The function is kept for backward compatibility. } \note{ The function is mainly useful for defining a set of colors to represent a known number of gradations. Such a set can be used to assign a grade to a small number of values (e.g. points on a scatterplot - but see \samp{color.scale} for large numbers) and display a color bar using \samp{gradient.rect} as a legend. } \value{A vector of hexadecimal color values as used by \samp{col}.} \author{Jim Lemon} \seealso{\link{rescale},\link{approx},\link{color.scale}} \examples{ # try it with red and blue endpoints and green midpoints. color.gradient(c(0,1),c(1,0.6,0.4,0.3,0),c(0.1,0.6)) } \keyword{misc} plotrix/man/cluster.overplot.Rd0000755000176000001440000000341212102170726016400 0ustar ripleyusers\name{cluster.overplot} \alias{cluster.overplot} \title{Shift overlying points into clusters} \usage{ cluster.overplot(x,y,away=NULL,tol=NULL,...) } \arguments{ \item{x,y}{Numeric data vectors or the first two columns of a matrix or data frame. Typically the x/y coordinates of points to be plotted.} \item{away}{How far to move overlying points in user units. Defaults to the width of a lower case "o" in the x direction and 5/8 of the height of a lower case "o" in the y direction. Must have both values.} \item{tol}{The largest distance between points that will be considered to be overlying. Defaults to 1/2 of the width of a lower case "o" in the x direction and 1/2 of the height of a lower case "o" in the y direction.} \item{...}{additional arguments returned as they are passed.} } \description{ \samp{cluster.overplot} checks for overlying points in the x and y coordinates passed. Those points that are overlying are moved to form a small cluster of up to nine points. For large numbers of overlying points, see \link{count.overplot} or \link{sizeplot}. If you are unsure of the number of overplots in your data, run \samp{count.overplot} first to see if there are any potential clusters larger than nine. } \value{ A list with two components. For unique x-y pairs the elements will be the same as in the original. For overlying points up to eight additional points will be generated that will create a cluster of points instead of one. } \keyword{misc} \author{Jim Lemon} \seealso{\link{count.overplot},\link{sizeplot}} \examples{ xy.mat<-cbind(sample(1:10,200,TRUE),sample(1:10,200,TRUE)) clusteredpoints<- cluster.overplot(xy.mat,col=rep(c("red","green"),each=100)) plot(clusteredpoints,col=clusteredpoints$col, main="Cluster overplot test") } plotrix/man/clplot.Rd0000755000176000001440000000225611324071540014347 0ustar ripleyusers\name{clplot} \title{Plot lines with colors determined by values.} \usage{ clplot(x,y,ylab=deparse(substitute(y)),xlab=deparse(substitute(x)), levels=seq(min(y)+(max(y)-min(y))/5,max(y)-(max(y)-min(y))/5,length.out=4), cols=c("black","blue","green","orange","red"),lty=1,showcuts=FALSE,...) } \alias{clplot} \arguments{ \item{x,y}{numeric data vectors.} \item{ylab,xlab}{Labels for the X and Y axes.} \item{levels}{Cut points to assign colors to the values of \samp{x} and \samp{y}.} \item{cols}{The colors to be assigned.} \item{lty}{The line type.} \item{showcuts}{Whether to show the positions of the cut points.} \item{...}{additional arguments passed to \samp{plot} or \samp{lines}.} } \description{ \samp{clplot} displays a plot of lines for which the colors are dependent upon the x and y values. \samp{clplot} is similar to \samp{color.scale.lines} except that while the latter calculates a color for each unique value, \samp{clplot} assigns colors to groups of values within the cutpoints defined by \samp{levels}. } \value{nil} \author{Carl Witthoft} \seealso{\link{plot}} \examples{ x<-seq(1,100) y<-sin(x/5)+x/20 clplot(x,y,main="Test of clplot") } \keyword{misc} plotrix/man/clock24.plot.Rd0000755000176000001440000000344111614225753015276 0ustar ripleyusers\name{clock24.plot} \title{Plot values on a 24 hour "clockface"} \usage{ clock24.plot(lengths,clock.pos,labels=NULL,label.pos=NULL,rp.type="r",...) } \alias{clock24.plot} \arguments{ \item{lengths}{numeric data vector. Magnitudes will be represented as line lengths, or symbol or polygon vertex positions.} \item{clock.pos}{numeric vector of positions on the 'clockface'. These must be in decimal hours and will be rescaled to radians.} \item{labels}{Labels to place at the circumference.} \item{label.pos}{Radial positions of the labels.} \item{rp.type}{Whether to plot radial lines, symbols or a polygon.} \item{...}{additional arguments are passed to \samp{radial.plot} and then to \samp{plot}.} } \description{ \samp{clock24.plot} displays a plot of radial lines, symbols or a polygon centered at the midpoint of the plot frame on a 24 hour 'clockface'. In contrast to the default behavior of \samp{radial.plot}, the positions are interpreted as beginning at vertical (000) and moving clockwise. If \samp{add=TRUE} is passed as one of the additional arguments, the values will be added to the current plot. If a \samp{radial.lim} argument was passed on the initial plot, it must be passed again to add values or the values will be displayed incorrectly. } \value{A list of the parameters altered by \link{radial.plot}.} \keyword{misc} \author{Jim Lemon} \seealso{\link{polar.plot},\link{radial.plot}} \examples{ testlen<-rnorm(24)*2+5 testpos<-0:23+rnorm(24)/4 clock24.plot(testlen,testpos,main="Test Clock24 (lines)",show.grid=FALSE, line.col="green",lwd=3) if(dev.interactive()) par(ask=TRUE) # now do a 'daylight' plot oldpar<-clock24.plot(testlen[7:19],testpos[7:19], main="Test Clock24 daytime (symbols)", point.col="blue",rp.type="s",lwd=3) # reset everything par(oldpar) } plotrix/man/clean.args.Rd0000755000176000001440000000224311146473510015070 0ustar ripleyusers\name{clean.args} \alias{clean.args} \alias{remove.args} \title{Remove inappropriate arguments from an argument list} \description{ Takes a list of arguments and eliminates those that are not appropriate for passing to a particular function (and hence would produce an error if passed). } \usage{ clean.args(argstr,fn,exclude.repeats=FALSE,exclude.other=NULL,dots.ok=TRUE) remove.args(argstr,fn) } \arguments{ \item{argstr}{a named list of arguments, e.g. from \samp{\dots}} \item{fn}{a function} \item{exclude.repeats}{(logical) remove repeated arguments?} \item{exclude.other}{a character vector of names of additional arguments to remove} \item{dots.ok}{should "..." be allowed in the argument list?} } \value{ \samp{clean.args} returns a list which is a copy of \samp{argstr} with arguments inappropriate for \samp{fn} removed; \samp{remove.args} removes the arguments for \samp{fn} from the list. } \author{Ben Bolker} \examples{ tststr <- list(n=2,mean=0,sd=1,foo=4,bar=6) clean.args(tststr,rnorm) try(do.call("rnorm",tststr)) do.call("rnorm",clean.args(tststr,rnorm)) remove.args(tststr,rnorm) ## add example of combining arg. lists? } \keyword{programming} plotrix/man/centipede.plot.Rd0000755000176000001440000001005011716163300015757 0ustar ripleyusers\name{centipede.plot} \alias{centipede.plot} \title{Display a centipede plot} \description{ Displays a centipede plot on the current graphics device. } \usage{ centipede.plot(segs,mct="mean",lower.limit="std.error", upper.limit=lower.limit,left.labels=NULL,right.labels=NULL,sort.segs=TRUE, main="",xlab=NA,pch=21,vgrid=NA,hgrid=NA,gridcol="lightgray",mar=NA,col=par("fg"), bg="green",...) } \arguments{ \item{segs}{a matrix of midpoints and limits calculated by \link{get.segs} OR a \samp{dstat} object returned by \samp{brkdn}.} \item{mct}{The function to use in calculating the midpoint of each segment.} \item{lower.limit}{The functions to use in calculating the lower limits for each subset of the data.} \item{upper.limit}{The functions to use in calculating the upper limits.} \item{left.labels}{The variable or subset labels to place at the left margin of the plot. Default values are provided.} \item{right.labels}{The variable or subset labels to place at the right margin of the plot.} \item{sort.segs}{Whether to sort the segments in ascending order.} \item{main}{Optional title for the plot.} \item{xlab}{Optional x axis label for the plot. The default NA displays a text label showing the midpoint and limit functions.} \item{pch}{The symbols to use when plotting midpoints.} \item{vgrid}{Optional vertical line(s) to display on the plot. Defaults to NA (none).} \item{hgrid}{Optional horizontal grid lines to display on the plot. Defaults to NA (none).} \item{gridcol}{The color for the vgrid and hgrid lines.} \item{mar}{Margin widths for the plot. Defaults to c(4,5,1,4) or c(4,5,3,4) if there is a title.} \item{col}{The color(s) of the limit lines and borders of the midpoint markers.} \item{bg}{The color(s) to fill the midpoint markers.} \item{...}{additional arguments passed to \samp{plot}.} } \details{ \samp{centipede.plot} displays one or more midpoints and limits as filled circles with horizontal error bars. It places labels on the left and right sides of the plot. If these labels are long, it may be necessary to pass explicit values to the \samp{mar} argument to leave enough room. The \samp{vgrid} argument is usually used to display an average value for all of the midpoints. If one or more values are passed in this argument, they will be displayed as vertical lines spanning the plot. The \samp{hgrid} argument acts like the \samp{grid} function, drawing dashed horizontal lines across the plot. If \samp{hgrid=NULL}, these lines will be drawn under the values displayed, which will be 1 to the number of values on the vertical axis. The user can pass explicit values if desired. With horizontal and optionally vertical grid lines, the centipede plot is practically equivalent to a dotplot with error bars. Similarly, centipede plots typically have a large number of subsets, and it may be necessary to start the graphics device with an aspect ratio that will prevent crowding of the labels when over 30 segments are displayed. The matrix \samp{segs} may be entered manually or read from a file. The first row specifies midpoints, the second and third rows the lower and upper limits respectively and the fourth row the number of valid observations. If there are no values for number of valid observations, just pass vector of blank strings with the \samp{right.labels} argument. If a \samp{dstat} object is passed as \samp{segs}, the function will calculate the lower and upper values according to the relevant arguments. This type of plot is also known as a caterpillar plot or a league table. } \value{nil.} \author{Jim Lemon} \seealso{\link{get.segs}} \examples{ testcp<-list("",40) for(i in 1:40) testcp[[i]]<-rnorm(sample(1:8,1)*50) segs<-get.segs(testcp) centipede.plot(segs,main="Test centipede plot",vgrid=0) # now leave out the number of valid observations, pass x labels and no right labels centipede.plot(segs[1:3,],main="Test centipede plot",vgrid=0,mar=c(4,5,3,2), left.labels=paste("X",1:40,sep=""),right.labels=rep("",40)) } \keyword{misc} plotrix/man/categoryReshape.Rd0000644000176000001440000000204611552277215016203 0ustar ripleyusers\name{categoryReshape} \alias{categoryReshape} \title{Convert object label/attribute label coding.} \description{Convert object label/attribute label coding to an object by attribute data frame.} \usage{ categoryReshape(x) } \arguments{ \item{x}{A matrix or data frame with at least two columns.} } \details{ \samp{categoryReshape} attempts to convert the first two columns of its input into a data frame in which rows represent objects and columns attributes. For each object, a value of 1 indicates that the object has that attribute, and a value of 0 that it does not. In set membership terms, a 1 indicates that the object is a member of that set and a 0 that it is not. } \value{A data frame (see Details).} \keyword{misc} \author{Jim Lemon} \seealso{\link{makeIntersectList}} \examples{ ns<-sample(1:8,20,TRUE) objects<-0 for(i in 1:length(ns)) objects<-c(objects,rep(i,ns[i])) attributes<-"Z" for(i in 1:length(ns)) attributes<-c(attributes,sample(LETTERS[1:8],ns[i])) setdf<-data.frame(objects[-1],attributes[-1]) categoryReshape(setdf) } plotrix/man/bumpchart.Rd0000755000176000001440000000503412112004674015034 0ustar ripleyusers\name{bumpchart} \alias{bumpchart} \title{Display a "bumps" chart} \description{ Display a chart with two of more columns of points in order of ascending values with lines connecting the points in a row. } \usage{ bumpchart(y,top.labels=colnames(y),labels=rownames(y),rank=TRUE, mar=c(2,8,5,8),pch=19,col=par("fg"),lty=1,lwd=1,...) } \arguments{ \item{y}{A numeric matrix or data frame which may contain NAs.} \item{top.labels}{The strings that will appear at the top of each column of points on the plot.} \item{labels}{The strings that will appear next to the outer columns of points.} \item{rank}{Whether to rank the values in \samp{y} before plotting.} \item{mar}{The margins to use for the bumps chart. Alter to your taste.} \item{pch}{The symbols to use when plotting the points.} \item{col}{The colors to use.} \item{lty}{The line types to use.} \item{lwd}{The line widths to use.} \item{...}{Additional arguments passed to \samp{matplot}.} } \details{ \samp{bumpChart} calls \samp{matplot} to plot the values in the transposed \samp{y} matrix or data frame, joining the points with lines. At the left and right edges of the plot, the labels identifying each row of points are displayed. This type of plot is often used to show the changing positions of entities over time, like the ranking in surveys in different years. For a similar, but more flexible plot, see \link{ladderplot}. Because of the way \samp{matplot} plots the values, the order of everything is reversed. If the user wants to rank in descending order, such as test scores, rank the values in the correct order before sending them to \samp{bumpChart}. } \value{nil} \author{Jim Lemon} \seealso{\link{matplot}} \examples{ # percentage of those over 25 years having completed high school # in 10 cities in the USA in 1990 and 2000 educattn<-matrix(c(90.4,90.3,75.7,78.9,66,71.8,70.5,70.4,68.4,67.9, 67.2,76.1,68.1,74.7,68.5,72.4,64.3,71.2,73.1,77.8),ncol=2,byrow=TRUE) rownames(educattn)<-c("Anchorage AK","Boston MA","Chicago IL", "Houston TX","Los Angeles CA","Louisville KY","New Orleans LA", "New York NY","Philadelphia PA","Washington DC") colnames(educattn)<-c(1990,2000) bumpchart(educattn,main="Rank for high school completion by over 25s") # now show the raw percentages and add central ticks bumpchart(educattn,rank=FALSE, main="Percentage high school completion by over 25s", line.info=list(lty=1:10,lwd=1,col=rainbow(10))) # margins have been reset, so use par(xpd=TRUE) boxed.labels(1.5,seq(65,90,by=5),seq(65,90,by=5)) par(xpd=FALSE) } \keyword{misc} plotrix/man/brkdnNest.Rd0000755000176000001440000000564511557245513015024 0ustar ripleyusers\name{brkdnNest} \alias{brkdnNest} \title{Perform a nested breakdown of numeric values} \description{Breaks down a numeric or categorical element of a data frame by one or more categorical elements.} \usage{ brkdnNest(formula,data,FUN=c("mean","sd"),label1="Overall",trueval=NA) } \arguments{ \item{formula}{A formula with a numeric element of a data frame on the left and one or more categorical elements on the right.} \item{data}{A data frame containing the elements in \samp{formula}.} \item{FUN}{The functions to be applied to successive breakdowns.} \item{label1}{The label to use for the overall value of the first function.} \item{trueval}{The value to use in calculating proportions or sums of a categorical response variable. See Details.} } \value{ A list with as many elements as there are functions in \samp{FUN}. This function is similar to \samp{brkdn} in the \pkg{prettyR} package, but is structured to be used with the \samp{barNest} function. It produces one or more measures for the overall data, then the subsets of the data defined by the first variable to the right of the tilde, then the subsets defined by the first and second variable, and so on. } \details{ \samp{brkdnNest} performs a nested breakdown of an element of a data frame by one or more categorical elements. For each category and optionally subcategories, the variable on the left of the formula is summarized as specified by the functions named in \samp{FUN}. If \samp{trueval} is not NA, brkdnNest will calculate the proportion of \samp{trueval} values in the response variable out of the total valid responses. If the function \samp{valid.n} is the first function in \samp{FUN}, the counts of the groups and subgroups will be returned. Two specialized summary functions are defined within \samp{brkdnNest} for use when the \samp{trueval} argument is not NA. \samp{sumbrk} returns the count of values in a factor equal to \samp{trueval}, while \samp{propbrk} returns the proportion of values equal to \samp{trueval}. The user should take care when specifying different summary functions. \samp{barNest} expects a measure of central tendency or counting function as the first function and measures of dispersion as the second and optionally third, if "error bars" are to be displayed. If two confidence interval functions are passed, the first must calculate the upper and the second the lower CI. The user must also decide whether the "error bars" have any useful meaning. } \author{Jim Lemon} \seealso{\link{by}} \examples{ brkdntest<-data.frame(Age=rnorm(100,25,10), Sex=sample(c("M","F"),100,TRUE), Marital=sample(c("M","X","S","W"),100,TRUE), Employ=sample(c("FT","PT","NO"),100,TRUE)) brkdnNest(formula=Age~Sex+Marital+Employ,data=brkdntest) # show the proportion of unemployed with binomial confidence intervals brkdnNest(formula=Employ~Sex+Marital,data=brkdntest, FUN=c("propbrk","binciWu","binciWl"),trueval="NO") } \keyword{misc} plotrix/man/brkdn.plot.Rd0000755000176000001440000001054011324071266015127 0ustar ripleyusers\name{brkdn.plot} \alias{brkdn.plot} \title{A point/line plotting routine} \description{Display a point/line plot of breakdowns of one or more variables.} \usage{ brkdn.plot(vars,groups=NA,obs=NA,data,mct="mean",md="std.error",stagger=NA, dispbar=TRUE,main="Breakdown plot",xlab=NA,ylab=NA,xaxlab=NA, ylim=NA,type="b",pch=1,lty=1,col=par("fg"),staxx=FALSE,...) } \arguments{ \item{vars}{The names or indices of one or more columns in a data frame. The columns must contain numeric data.} \item{groups}{The name or index of a column in a data frame that classifies the values in \samp{vars} into different, usually fixed effect, levels.} \item{obs}{The name or index of a column in a data frame that classifies the values in \samp{vars} into different, usually random effect, levels.} \item{data}{The data frame.} \item{mct}{The measure of central tendency to calculate for each group.} \item{md}{The measure of dispersion to calculate, NA for none.} \item{stagger}{The amount to offset the successive values at each horizontal position as a proportion of the width of the plot. The calculated default is usually adequate. Pass zero for none.} \item{dispbar}{Whether to display the measures of dispersion as bars.} \item{main}{The title at the top of the plot.} \item{xlab,ylab}{The labels for the X and Y axes respectively. There are defaults, but they are basic.} \item{xaxlab}{Optional labels for the horizontal axis ticks.} \item{ylim}{Optional vertical limits for the plot.} \item{type}{Whether to plot symbols, lines or both (as in \samp{plot}).} \item{pch}{Symbol(s) to plot.} \item{lty}{Line type(s) to plot.} \item{col}{Color(s) for the symbols and lines.} \item{staxx}{Whether to call \link{staxlab} to display the X axis labels.} \item{...}{additional arguments passed to \samp{plot}.} } \value{ A list of two matrices of dimension \samp{length(levels(groups))} by \samp{length(levels(obs))}. The first contains the measures of central tendency calculated and its name is the name of the function passed as \samp{mct}. The second contains the measures of dispersion and its name is the name of the function passed as \samp{md}. If both \samp{groups} and \samp{obs} are not NA, the rows of each matrix will be the \samp{groups} and the columns the \samp{obs}. If \samp{obs} is NA, the rows will be the \samp{groups} and the columns the \samp{vars}. If \samp{groups} is NA, the rows will be the \samp{vars} and the columns the \samp{obs}. That is, if \samp{vars} has more than one element, if \samp{obs} is NA, the elements of \samp{vars} will be considered to represent observations, while if \samp{groups} is NA, they will be considered to represent groups. At least one of \samp{groups} and \samp{obs} must be not NA or there is no point in using \samp{brkdn.plot}. } \details{ \samp{brkdn.plot} displays a plot useful for visualizing the breakdown of a response measure by two factors, or more than one response measure by either a factor representing something like levels of treatment (\samp{groups}) or something like repeated observations (\samp{obs}). For example, if observations are made at different times on data objects that receive different treatments, the \samp{groups} factor will display the measures of central tendency as points/lines with the same color, symbol and line type, while the \samp{obs} factor will be represented as horizontal positions on the plot. If \samp{obs} is numeric, its unique values will be used as the positions, if not, 1 to the number of unique values. This is a common way of representing changes over time intervals for experimental groups. } \author{Jim Lemon} \seealso{\link{dispbars}} \examples{ test.df<-data.frame(a=rnorm(80)+4,b=rnorm(80)+4,c=rep(LETTERS[1:4],each=20), d=rep(rep(letters[1:4],each=4),5)) # first use the default values brkdn.plot("a","c","d",test.df,pch=1:4,col=1:4) # now jazz it up a bit using medians and median absolute deviations # and some enhancements bp<-brkdn.plot("a","c","d",test.df,main="Test of the breakdown plot", mct="median",md="mad",xlab="Temperature range", ylab="Cognition", xaxlab=c("10-15","16-20","21-25","25-30"),pch=1:4,lty=1:4,col=1:4) es<-emptyspace(bp) legend(es,legend=c("Sydney","Gosford","Karuah","Brisbane"),pch=1:4, col=1:4,lty=1:4,xjust=0.5,yjust=0.5) } \keyword{misc} plotrix/man/boxed.labels.Rd0000755000176000001440000000544611773022224015423 0ustar ripleyusers\name{boxed.labels} \alias{boxed.labels} \title{ Place labels in boxes } \description{ Places labels in boxes on an existing plot } \usage{ boxed.labels(x,y=NA,labels, bg=ifelse(match(par("bg"),"transparent",0),"white",par("bg")), border=TRUE,xpad=1.2,ypad=1.2,srt=0,cex=1,adj=0.5,...) } \arguments{ \item{x,y}{x and y position of the centers of the labels. \samp{x} can be an \link{xy.coords} list.} \item{bg}{The fill color of the rectangles on which the labels are displayed (see Details).} \item{labels}{Text strings} \item{border}{Whether to draw borders around the rectangles.} \item{xpad,ypad}{The proportion of the rectangles to the extent of the text within.} \item{srt}{Rotation of the labels. If 90 or 270 degrees, the box will be rotated 90 degrees.} \item{cex}{Character expansion. See \samp{text}.} \item{adj}{left/right adjustment. If this is set outside the function, the box will not be aligned properly.} \item{...}{additional arguments passed to \samp{text}.} } \details{ The label(s) are displayed on a rectangular background. This may be useful for visibility and is the reason that "transparent" background is not available. With the default \samp{textcol=NA}, the function tries to work out whether white or black text will be more easily read based on the background color and displays the text accordingly. If the user specifies text colors in the additional arguments, these colors will override the automatic white/black above - see the last example. Only right angle rotations are allowed in \samp{boxed.labels}. \emph{Important change}: \samp{xpad} and \samp{ypad} are now the full proportion of the box to text, not half. The user can now call \samp{cylindrect} or \samp{gradient.rect} for the background rectangle. } \note{ This function is best for regularly spaced labels where overlapping is not a problem. See \link{thigmophobe.labels} for placing labels where overlap is likely. } \value{nil} \author{Jim Lemon - thanks to Thorn Thaler for the code allowing user-specified text colors} \seealso{\link{spread.labels}, \link{thigmophobe.labels}} \examples{ x<-rnorm(10) y<-rnorm(10) plot(x,y,type="p") nums<-c("one","two","three","four","five","six","seven","eight","nine","ten") boxed.labels(x,y-0.1,nums) # now label a barplot xpos<-barp(c(1,3,2,4)) boxed.labels(xpos$x,0.5,nums[1:4]) # and add labels below the x axis ticks boxed.labels(xpos$x,-0.4,c("First","Second","Third","Fourth")) # perform a PCA on the "swiss" dataset and plot the first two components data(swiss) swiss.pca<-prcomp(swiss) plot(swiss.pca$rotation[,1:2],xlim=c(-1,0.2),main="PCA of swiss dataset", type="n") boxed.labels(swiss.pca$rotation[1:6],swiss.pca$rotation[7:12],ypad=1.5, colnames(swiss),bg=c("red","purple","blue","blue","darkgreen","red"), col="yellow") } \keyword{misc} plotrix/man/box.heresy.Rd0000644000176000001440000000367011773557674015167 0ustar ripleyusers\name{box.heresy} \alias{box.heresy} \title{Display a sort of box plot} \usage{ box.heresy(x,y,uinner,linner=uinner,ulim,llim=ulim,intervals=FALSE, arrow.cap=NA,pch=22,main="",xlab="",ylab="",xaxlab=NA,col="white",do.first=NULL,...) } \arguments{ \item{x,y}{Vectors of numeric values representing measures of central tendency.} \item{uinner,linner}{Vectors of numeric values representing "inner" measures of dispersion.} \item{ulim,llim}{Vectors of numeric values representing "outer" measures of dispersion.} \item{intervals}{Whether the values for dispersion are intervals (TRUE) or absolute limits (FALSE).} \item{arrow.cap}{The width of the cap on the "whiskers" relative to the width of the plot. Defaults to the same width as the outer box.} \item{pch}{The symbol to be used to represent the measure(s) of central tencency in the box.} \item{main}{The title for the plot (i.e. \samp{main}).} \item{xlab,ylab}{The x and y axis labels.} \item{xaxlab}{Optional labels for the boxes.} \item{col}{The fill colors for the "inner" rectangles.} \item{do.first}{An expression that will be evaluated before anything is displayed.} \item{...}{additional arguments passed to the \samp{dispersion} function.} } \description{ \samp{box.heresy} displays a box plot in which a symbol represents a measure of central tendency, a surrounding box that represents an "inner" measure of dispersion (e.g. standard error) and whiskers that represent an "outer" measure of dispersion (e.g. standard deviation). The function is pretty basic at this time and will probably change a bit. } \value{nil} \author{Jim Lemon - thanks to Gianni Lavaredo for the suggestion} \keyword{misc} \seealso{\link{plot}, \link{boxplot}} \examples{ y<-runif(5) ulim<-runif(5) llim<-runif(5) uinner<-ulim/2 linner<-llim/2 box.heresy(y,uinner=uinner,linner=linner,ulim=ulim,llim=llim, intervals=TRUE,main="The heretical boxplot", xlab="Number of observations",ylab="Value") } plotrix/man/binciWu.Rd0000755000176000001440000000172711557744311014467 0ustar ripleyusers\name{binciWu} \alias{binciWu} \title{Upper binomial confidence limit} \description{ Calculates an upper binomial confidence limit using the Wilson approximation. } \usage{ binciWu(x,n,alpha=0.05,trueval=NA,na.rm=TRUE) } \arguments{ \item{x}{The number of successes or failures for which the CI is to be calculated.} \item{n}{The number of trials as above.} \item{alpha}{The desired coverage - 0.05 produces 95 percent coverage} \item{trueval}{The value representing the outcome of interest for the CI.} \item{na.rm}{Argument needed to make this work} } \details{ \samp{binciWu} calculates the upper binomial confidence limit for the given number of successes and trials. It is mainly to allow binomial confidence limits to be calculated in the \samp{brkdnNest} function, which is why the upper and lower CIs are calculated separately. } \value{The upper binomial confidence interval} \author{Jim Lemon} \seealso{\link{binciWl}} \examples{ binciWu(5,42) } \keyword{misc} plotrix/man/binciWl.Rd0000755000176000001440000000172311557744301014451 0ustar ripleyusers\name{binciWl} \alias{binciWl} \title{Lower binomial confidence limit} \description{ Calculates a lower binomial confidence limit using the Wilson approximation. } \usage{ binciWl(x,n,alpha=0.05,trueval=NA,na.rm=TRUE) } \arguments{ \item{x}{The number of successes or failures for which the CI is to be calculated.} \item{n}{The number of trials as above.} \item{alpha}{The desired coverage - 0.05 produces 95 percent coverage} \item{trueval}{The value representing the outcome of interest for the CI.} \item{na.rm}{Argument needed to make this work} } \details{ \samp{binciWl} calculates the lower binomial confidence limit for the given number of successes and trials. It is mainly to allow binomial confidence limits to be calculated in the \samp{brkdnNest} function, which is why the upper and lower CIs are calculated separately. } \value{The lower binomial confidence limit} \author{Jim Lemon} \seealso{\link{binciWu}} \examples{ binciWl(5,42) } \keyword{misc} plotrix/man/bin.wind.records.Rd0000755000176000001440000000234611334500736016227 0ustar ripleyusers\name{bin.wind.records} \alias{bin.wind.records} \title{Classify wind direction and speed records} \description{Classifies wind direction and speed records into a matrix of percentages of observations in speed and direction bins.} \usage{ bin.wind.records(winddir,windspeed,ndir=8,radians=FALSE, speed.breaks=c(0,10,20,30)) } \arguments{ \item{winddir}{A vector of wind directions.} \item{windspeed}{A vector of wind speeds corresponding to the above directions.} \item{ndir}{Number of direction bins in a compass circle.} \item{radians}{Whether wind directions are in radians.} \item{speed.breaks}{Minimum wind speed for each speed bin.} } \details{ \samp{bin.wind.records} bins a number of wind direction and speed records into a matrix of percentages of observations that can be used to display a cumulative wind rose with \samp{oz.windrose} The defaults are those used by the Australian Bureau of Meteorology. } \value{ A matrix of percentages in which the rows represent wind speed categories and the columns represent wind direction categories. } \author{Jim Lemon} \seealso{\link{oz.windrose}} \examples{ winddir<-sample(0:360,100,TRUE) windspeed<-sample(0:40,100,TRUE) bin.wind.records(winddir,windspeed) } \keyword{misc} plotrix/man/battleship.plot.Rd0000644000176000001440000000426012110347547016167 0ustar ripleyusers\name{battleship.plot} \alias{battleship.plot} \title{Display a matrix of values as the widths of stacked rectangles} \usage{ battleship.plot(x,mar=c(2,5,5,1),col="white",border="black", main="",xlab="",ylab="",xaxlab=NA,yaxlab=NA,cex.labels=1, maxxspan=0.45,maxyspan=0.45) } \arguments{ \item{x}{A matrix or data frame containing numeric values. See the example.} \item{mar}{Margins for the plot.} \item{col}{The fill colors for the rectangles.} \item{border}{The border colors for the rectangles.} \item{main}{The title for the plot (i.e. \samp{main}).} \item{xlab,ylab}{The x and y axis labels.} \item{xaxlab,yaxlab}{Optional labels for the rows and columns.} \item{cex.labels}{Character expansion for the row and column labels.} \item{maxxspan,maxyspan}{Scaling factor for the widths and heights of the rectangles so that they don't overlap.} } \description{ \samp{battleship.plot} displays a matrix of rectangles, with widths proportional to the values in \samp{x}. The values are scaled so that half the width of the largest rectangle is equal to \samp{maxxspan} in user units. This prevents the rectangles from overlapping. The user can adjust the spacing of the stacks of rectangles by changing \samp{maxxspan}. Similarly, maxyspan controls the spacing between rectangles in the vertical direction. The labels for each stack of plots (the columns of x) are displayed at the top of the plot, angled at 45 degrees. The labels for each row of rectangles in the stacks (the rows of x) are displayed at the left. Long labels for either may require adjusting the \samp{mar} argument. The function will try to extract the labels \samp{xaxlab} and \samp{yaxlab} from the matrix column and row names respectively if none are passed. } \value{nil} \author{Jim Lemon - thanks to Adam Maltese for the suggestion} \keyword{misc} \seealso{\link{plot}, \link{staxlab}} \examples{ x<-matrix(sample(10:50,100,TRUE),10) xaxlab=c("One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten") yaxlab=c("First","Second","Third","Fourth","Fifth","Sixth","Seventh", "Eighth","Ninth","Tenth") battleship.plot(x,xlab="The battle has just begun",main="Battleship1", xaxlab=xaxlab,yaxlab=yaxlab) } plotrix/man/barp.Rd0000755000176000001440000002045411773560462014014 0ustar ripleyusers\name{barp} \alias{barp} \title{A bar plotting routine} \description{Display a bar plot} \usage{ barp(height,width=0.4,names.arg=NULL,legend.lab=NULL,legend.pos=NULL, col=NULL,border=par("fg"),main=NULL,xlab="",ylab="",xlim=NULL,ylim=NULL, x=NULL,staxx=FALSE,staxy=FALSE, height.at=NULL,height.lab=NULL, cex.axis=par("cex.axis"),pch=NULL,cylindrical=FALSE,shadow=FALSE, do.first=NULL,ylog=FALSE,srt=NA) } \arguments{ \item{height}{A numeric vector, matrix or data frame that will be represented as the heights of bars.} \item{width}{Half the width of a single bar or group of bars in X axis units.} \item{names.arg}{The labels for the bars or groups of bars.} \item{legend.lab}{Labels for an optional legend. If NULL, no legend is displayed.} \item{legend.pos}{Optional position for the legend as a list with \samp{x} and \samp{y} components. If this is NULL, \samp{locator} will be called.} \item{col}{The fill colors for the bars. The default is no fill.} \item{border}{The border for the bars.} \item{main}{The title at the top of the plot.} \item{xlab,ylab}{The labels for the X and Y axes respectively.} \item{xlim,ylim}{Optional horizontal and vertical limits for the plot.} \item{x}{Optional horizontal positions for the bars. Defaults to 1:length(height).} \item{staxx,staxy}{Whether to use \link{staxlab} to stagger the X or Y axis tick labels.} \item{height.at}{Optional positions of the tick marks on the Y axis.} \item{height.lab}{Optional tick labels for the Y axis.} \item{cex.axis}{Character expansion for the axis labels.} \item{pch}{Symbol(s) to fill the bars. See Details.} \item{cylindrical}{Whether to give the bars a cylindrical appearance by shading them.} \item{shadow}{Whether to place a shadow behind the bars.} \item{do.first}{An optional expression that will be evaluated before anything else is displayed on the plot. Useful for background colors or lines.} \item{ylog}{Logical for whether a log scale is to be used. see details.} \item{srt}{Rotation of axis labels if staxx or staxy is TRUE (see \samp{staxlab}).} } \value{ A list containing two components of the same form as \samp{height}: \item{x}{The centers of the bars displayed.} \item{y}{The heights of the bars.} } \details{ \samp{barp} displays a bar plot similar to \samp{barplot} but with axes and horizontal bar positions more like \samp{plot}. Bars or groups of bars are centered on integral X values by default, and so both the width and spacing of the bars are controlled by a single number. If the user passes expicit \samp{x} values, those values will determine the spacing. If \samp{height} is a vector, single bars representing each value will be displayed centered at \samp{1:length(height)} unless the user has specified \samp{x} values. If \samp{height} is a matrix, 2D array, or data frame, a group of bars will be drawn for each column, with the values of the group taken from the rows of that column. Explicit x values cannot be used with a matrix, however, by adjusting the values of x, grouped bars can be displayed. The values from \samp{freq} or \samp{brkdn} in the prettyR package can be used as the \samp{height} argument. The value from \samp{table} can also be passed as \samp{height}, as can a 2D array returned from the \samp{by} function. Bars are empty by default but fill colors can be defined in several ways. If a single color is passed, all bars will be the same color. If \samp{height} is a vector, colors will be recycled or some will be ignored if the length of \samp{col} is not equal to that of \samp{height}. If \samp{height} is a matrix or data frame, the user may pass a vector of colors equal to the number of rows in \samp{height} or a matrix of colors of the same dimensions as \samp{height}. Other sequences of color will probably not result in an easy to interpret plot. \samp{barp} is intended to simplify illustrating categorical data for which both the variable designations and the categories are names, as on many multiple choice questions. \samp{height.at} and \samp{height.lab} allow the user to place labels on the vertical axis, usually representing the options. If \samp{staxx} or \samp{staxy} are TRUE, the labels on the horizontal or vertical axes respectively will be staggered, allowing the user to use many or lengthy variable or value labels. If \samp{srt} is not NA, these labels will be rotated counterclockwise by that value as angles in degrees instead of staggered. \samp{barp} allows two enhancements that may be useful in those areas where fancy plots are appreciated. One is to give the bars a cylindrical look by shading the color. The other is to place an apparent shadow behind each bar. Both of these effects appear as though the light is coming from the upper left, and this is hard coded. You can add error bars by calling \samp{dispbars}, but many advise against this. If \samp{legend.lab} is not NULL, a legend will be displayed. If \samp{legend.pos} is NA, \samp{locator} is called to place the legend. On Windows, the alert may not appear on the console, and the function will appear to hang unless the user clicks on the console window or the plot. The \samp{ylog} argument produces a log scale on the y axis. Currently, neither \samp{pretty} nor \samp{axTicks} seems to produce a nice set of axis ticks, so it is best to pass the positions of these in \samp{height.at}. If the \samp{pch} argument is not NULL, barp will display white bars filled with the symbols specified in \samp{pch}. With grouped bars, this must be a matrix with the same form as the \samp{col} argument. This option allows a black and white bar plot to be produced. } \author{Jim Lemon} \seealso{\link{staxlab}, \link{barplot}, \link{cylindrect}, \link{gradient.rect}} \examples{ # get some extra room on the left par(mar=c(5,5,4,2)) # make up some happiness data, as so many seem to do happyday<-data.frame(Monday=c(2.3,3.4),Tuesday=c(2.8,3.3),Wednesday=c(3.2,3.1), Thursday=c(3.6,2.8),Friday=c(4.2,2.6),Saturday=c(4.5,2.9),Sunday=c(4.1,2.8)) happylabels<-c("Utterly dashed","Rather mopey","Indifferent","Somewhat elated", "Euphoric") barp(happyday,names.arg=names(happyday),legend.lab=c("Slaves","Unemployed"), legend.pos=list(x=2,y=4.5),col=c("#ee7700","#3333ff"),main="9AM happiness by weekday", xlab="Day of week",ylab="Happiness rating",ylim=c(1,5),staxx=TRUE,staxy=TRUE, height.at=1:5,height.lab=happylabels,cex.axis=0.9,cylindrical=TRUE, shadow=TRUE) # now do a plot with colors scaled to the sex ratio (real data!) sexratio<-c(0.24,0.35,0.09,0.59,0.63,0.34,0.7,0.6) # the fun ratings are once again a pack of lies funrating<-c(3.2,3.5,1.5,5.4,4.5,2.7,6.8,4.9) funstudy<-c("Astronomy","Chemistry","Economics","Anthropology","Linguistics", "Math/Stats","Psychology","Sociology") funlabels<-c("Torture","Agony","Boredom","Neutral","Entertaining","Exhilarating", "Maniacal") # xrange is used to get the colors to match the 0-100% scale barp(funrating,names.arg=funstudy,main="Fun ratings for various areas of study", col=color.scale(sexratio,c(0.2,1),c(0.2,0.4),c(1,0.4),xrange=c(0,1)), xlab="Study",ylab="Rating",height.at=1:7,height.lab=funlabels,ylim=c(1,7), staxx=TRUE,staxy=TRUE,cex.axis=0.9) # here we want the full scale from zero to one color.legend(2,6,4,6.4,legend=c("100\% guys","100\% girls"), rect.col=color.scale(seq(0,1,by=0.25),c(0.2,1),c(0.2,0.4),c(1,0.4))) par(mar=c(5,4,4,2)) # use barp to display a multiple histogram with a shaded background # notice how the expression uses local variables inside the barp function gradbg<-expression(gradient.rect(xlim[1],ylim[1],xlim[2],ylim[2], c(1,0.5,1),c(1,0.5,1),c(1,0.5,1),gradient="y",nslices=100)) h1<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) h2<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) h3<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) hmat<-matrix(c(h1,h2,h3),nrow=3,byrow=TRUE) barp(hmat,names.arg=names(h1),width=0.45,col=2:4,do.first=gradbg, main="Multiple histogram using barp",xlab="Bins",ylab="Frequency") legend(3.8,50,c("h1","h2","h3"),fill=2:4) # now display a positive/negative plot barp(c(2,-3,4,-5,6,-7,8),main="Positive/negative plot", xlab="Alternating colors",ylab="For alternating values", col=2+(c(2,-3,4,-5,6,-7,8)>0)) } \keyword{misc} plotrix/man/barlabels.Rd0000644000176000001440000000341011771040071014770 0ustar ripleyusers\name{barlabels} \alias{barlabels} \title{Label the bars on a barplot} \description{Displays labels on a plot, usually a bar plot.} \usage{ barlabels(xpos,ypos,labels=NULL,cex=1,prop=0.5,miny=0,offset=0,...) } \arguments{ \item{xpos}{A vector, matrix or data frame of x positions for the labels.} \item{ypos}{A vector, matrix or data frame of y positions for the labels.} \item{labels}{The labels to display. Defaults to the values of y.} \item{cex}{Relative size of the labels. See \samp{text}.} \item{prop}{The proportion of \samp{ypos} at which to place the labels. Defaults to 0.5 (the middle).} \item{miny}{The minimum value at which to display labels.} \item{offset}{Amount to horizontally offset successive labels in case of vertical overlaps.} \item{...}{Extra arguments passed to \samp{boxed.labels}.} } \details{ \samp{barlabels} places labels on a plot at horizontal positions \samp{xpos} and vertical positions \samp{ypos} * \samp{pos}. The typical use of this function is to place labels on bars, by default in the middle of the bars. To put labels just over the tops of the bars, set \samp{prop} to 1 and add a constant amount to \samp{ypos}. } \value{nil} \author{Jim Lemon} \seealso{\link{boxed.labels}} \examples{ heights<-c(14,20,9,31,17) barpos<-barplot(heights,main="A redundant bar plot") # show the usual value labels on the bars barlabels(barpos,heights) # now with stacked bars and offsets heights<-matrix(sample(c(1,2,10,15),20,TRUE),ncol=4) barpos<-barplot(heights,main="Another redundant bar plot") barlabels(barpos,heights,offset=0.1) # finally use barp for the plot barpos<-barp(heights,main="A third and final bar plot",col=2:6, names.arg=paste("Day",1:4)) barlabels(barpos$x,barpos$y,matrix(LETTERS[1:5],nrow=5,ncol=4)) } \keyword{misc} plotrix/man/barNest.Rd0000755000176000001440000001655011755436232014465 0ustar ripleyusers\name{barNest} \alias{barNest} \title{Display a nested breakdown of numeric values} \description{Breaks down the elements of a data frame by one or more categorical elements and displays the breakdown as a bar plot.} \usage{ barNest(formula=NULL,data=NULL,FUN=c("mean","sd"),ylim=NULL, main="",xlab="",ylab="",shrink=0.1,errbars=FALSE,col=NA, labelcex=1,lineht=NA,showall=TRUE,barlabels=NULL,showlabels=TRUE,mar=NULL, arrow.cap=NA,trueval=NA) } \arguments{ \item{formula}{A formula with a numeric element of a data frame on the left and one or more categorical elements on the right.} \item{data}{A data frame containing the elements in \samp{formula}.} \item{FUN}{The functions to apply to x.} \item{ylim}{Optional y limits for the plot, usually necessary for counts.} \item{main}{Title for the plot.} \item{xlab,ylab}{Axis labels for the plot. The x axis label is typically blank} \item{shrink}{The proportion to shrink the width of the bars at each level.} \item{errbars}{Whether to display error bars on the lowest level of breakdown.} \item{col}{The colors to use to fill the bars. See Details.} \item{labelcex}{Character size for the group labels.} \item{lineht}{The height of a line of text in the lower margin of the plot in user units. This will be calculated by the function if a value is not passed.} \item{showall}{Whether to display bars for the entire breakdown.} \item{barlabels}{Optional group labels that may be useful if the factors used to break down the numeric variable are fairly long strings.} \item{showlabels}{Whether to display the labels below the bars.} \item{mar}{If not NULL, a four element vector to set the plot margins. If new margins are set, the user must reset the margins after the function exits.} \item{arrow.cap}{The width of the "cap" on error bars in user units, calculated on the basis of the number of bars in the final breakdown if NA.} \item{trueval}{If this is not NA, the call to \samp{brkdnNest} will return the proportions of the response variable that are equal to \samp{trueval}. See Details.} } \value{The summary list produced by brkdnNest.} \details{ \samp{barNest} displays a bar plot illustrating the hierarchic breakdown of the elements of a data frame. The breakdown is performed by \samp{brkdnNest} and the actual display is performed by \samp{drawNestedBars}. The heights of the bars will be proportional to the values returned by the first function in \samp{FUN}. If \samp{showall} is TRUE, the entire nested breakdown will be displayed. This can be useful in visualizing the relationship between groups and subgroups in a compact format. If \samp{trueval} is not NA and brkdnNest is called to calculate the values for the heights of the bars, the proportions of the dichotomous response variable that are equal to \samp{trueval} will be returned. A number of functions can be passed in the \samp{FUN} argument. Two functions, \samp{propbrk} and \samp{valid.n} that are provided can be used as bar heights, giving proportions and counts in each group and subgroup respectively. Binomial confidence limits can be added to the proportions returned by \samp{propbrk} with \samp{binciWl} and \samp{binciWu} as in the second last example. If \samp{valid.n} is the first element of \samp{FUN}, the "overall" bar and label will be suppressed, as they are not informative. The colors of the bars are determined by \samp{col}. If \samp{showall} is FALSE, the user only need pass a vector of colors, usually the same length as the number of categories in the final (last on the right side) element in the formula. If \samp{showall} is TRUE and the user wants to color all of the bars, a list with as many elements as there are levels in the breakdown should be passed. Each element should be a vector of colors, again usually the same length as the number of categories. As the categorical variables are likely to be factors, it is important to remember that the colors must be in the correct order for the levels of the factors. When the levels are not in the default alphanumeric order, it is quite easy to get this wrong. As a \samp{barNest} plot with more than a few factors and levels in each factor is quite dense, easily distinguished colors for each level of the breakdown may be preferable. } \author{Jim Lemon and Ofir Levy} \references{ Lemon, J. & Levy, O. (2011) barNest: Illustrating nested summary measures. Statistical Computing and Graphics Newsletter of the American Statistical Association, 21(2): 5-10. } \seealso{\link{brkdnNest}, \link{drawNestedBars}, superbarplot(UsingR)} \examples{ # recreate the Titanic data frame and show the three way breakdown titanic<-data.frame( class=c(rep("1st",325),rep("2nd",285),rep("3rd",706),rep("Crew",885)), age=c(rep("Adult",319),rep("Child",6),rep("Adult",261),rep("Child",24), rep("Adult",627),rep("Child",79),rep("Adult",885)), sex=c(rep("M",175),rep("F",144),rep("M",5),rep("F",1), rep("M",168),rep("F",93),rep("M",11),rep("F",13), rep("M",462),rep("F",165),rep("M",48),rep("F",31), rep("M",862),rep("F",23)), survived=c(rep("Yes",57),rep("No",118),rep("Yes",140),rep("No",4),rep("Yes",6), rep("Yes",14),rep("No",154),rep("Yes",80),rep("No",13),rep("Yes",24), rep("Yes",75),rep("No",387),rep("Yes",76),rep("No",89), rep("Yes",13),rep("No",35),rep("Yes",14),rep("No",17), rep("Yes",192),rep("No",670),rep("Yes",20),rep("No",3))) require(plotrix) titanic.colors<-list("gray90",c("#0000ff","#7700ee","#aa00cc","#dd00aa"), c("#ddcc00","#ee9900"),c("pink","lightblue")) barNest(survived~class+age+sex,titanic,col=titanic.colors,showall=TRUE, main="Titanic survival by class, age and sex",ylab="Proportion surviving", FUN="propbrk",shrink=0.15,trueval="Yes") # now show the actual numbers of passengers barNest(survived~class+age+sex,titanic,col=titanic.colors,showall=TRUE, main="Titanic passengers and crew by class, age and sex",ylab="Number", FUN="valid.n",shrink=0.15) # to see this properly displayed, start a wide plot window # x11(width=10) test.df<-data.frame(Age=rnorm(100,25,10), Sex=sample(c("Male","Female"),100,TRUE), Marital=sample(c("Div","Mar","Sing","Wid"),100,TRUE), Employ=sample(c("FT","PT","Un"),100,TRUE)) test.col<-list(Overall="gray",Sex=c("pink","lightblue"), Marital=c("mediumpurple","orange","tan","lightgreen"), Employ=c("#1affd8","#caeecc","#ff90d0")) barNest(formula=Age~Sex+Marital+Employ,data=test.df,ylab="Mean age (years)", main="Mean age by subgroups",errbars=TRUE,col=test.col) # set up functions for 20th and 80th percentiles q20<-function(x,na.rm=TRUE) return(quantile(x,probs=0.2,na.rm=TRUE)) q80<-function(x,na.rm=TRUE) return(quantile(x,probs=0.8,na.rm=TRUE)) # show the asymmetric dispersion measures barNest(formula=Age~Sex+Marital+Employ,data=test.df,ylab="Mean age (years)", main="Use median and quantiles for dispersion",FUN=c("median","q80","q20"), errbars=TRUE,col=test.col) barNest(formula=Employ~Sex+Marital,data=test.df,ylab="Proportion unemployed", main="Show the proportion unemployed",FUN=c("propbrk","binciWu","binciWl"), errbars=TRUE,col=test.col,trueval="Un") barNest(formula=Age~Sex+Marital+Employ,data=test.df,ylab="Counts", main="Show the counts in subgroups (final level only)",FUN="valid.n", col=test.col,showall=FALSE,ylim=c(0,10)) barNest(formula=Age~Sex+Marital+Employ,data=test.df,ylab="Counts", main="Show all the counts in subgroups",FUN="valid.n",mar=c(5,5,4,2), col=test.col) } \keyword{misc} plotrix/man/axis.mult.Rd0000755000176000001440000000337711324070372015005 0ustar ripleyusers\name{axis.mult} \alias{axis.mult} \title{ Display an axis with values having a multiplier } \description{ An axis is displayed on an existing plot where the tick values are divided by a multiplier and the multiplier is displayed next to the axis. } \usage{ axis.mult(side=1,at=NULL,labels,mult=1,mult.label,mult.line, mult.labelpos=NULL,...) } \arguments{ \item{side}{which side to display} \item{at}{where to place the tick marks - defaults to \samp{axTicks()}} \item{labels}{tick labels - defaults to at/mult} \item{mult}{the multiplier factor} \item{mult.label}{the label to show the multiplier - defaults to "x mult"} \item{mult.line}{the margin line upon which to show the multiplier} \item{mult.labelpos}{where to place \samp{mult.label} - defaults to centered and outside the axis tick labels} \item{...}{additional arguments passed to \samp{axis}.} } \value{nil} \details{ \samp{axis.mult} automates the process of displaying an axis with a multiplier applied to the tick values. By default it will divide the default axis tick labels by \samp{mult} and place \samp{mult.label} where \samp{xlab} or \samp{ylab} would normally appear. Thus the plot call should set the relevant label to an empty string in such cases. It is simplest to call \samp{plot} with \samp{axes=FALSE} and then display the box and any standard axes before calling \samp{axis.mult}. } \note{ While \samp{axis.mult} will try to display an axis on any side, the top and right margins will require adjustment using \samp{par} for \samp{axis.mult} to display properly. } \author{Jim Lemon} \seealso{\link{axis}, \link{mtext}} \examples{ plot(1:10*0.001,1:10*100,axes=FALSE,xlab="",ylab="",main="Axis multipliers") box() axis.mult(1,mult=0.001) axis.mult(2,mult=100) } \keyword{misc} plotrix/man/axis.break.Rd0000755000176000001440000000332011405140660015072 0ustar ripleyusers\name{axis.break} \alias{axis.break} \title{ Place a "break" mark on an axis } \description{ Places a "break" mark on an axis on an existing plot. } \usage{ axis.break(axis=1,breakpos=NULL,pos=NA,bgcol="white",breakcol="black", style="slash",brw=0.02) } \arguments{ \item{axis}{which axis to break} \item{breakpos}{where to place the break in user units} \item{pos}{position of the axis (see \link{axis}).} \item{bgcol}{the color of the plot background} \item{breakcol}{the color of the "break" marker} \item{style}{Either \samp{gap}, \samp{slash} or \samp{zigzag}} \item{brw}{break width relative to plot width} } \value{nil} \details{ The \samp{pos} argument is not needed unless the user has specified a different position from the default for the axis to be broken. } \note{ There is some controversy about the propriety of using discontinuous coordinates for plotting, and thus axis breaks. Discontinuous coordinates allow widely separated groups of values or outliers to appear without devoting too much of the plot to empty space. The major objection seems to be that the reader will be misled by assuming continuous coordinates. The \samp{gap} style that clearly separates the two sections of the plot is probably best for avoiding this. } \author{Jim Lemon and Ben Bolker} \seealso{\link{gap.plot}} \examples{ plot(3:10,main="Axis break test") # put a break at the default axis and position axis.break() axis.break(2,2.9,style="zigzag") twogrp<-c(rnorm(10)+4,rnorm(10)+20) gap.plot(twogrp,gap=c(8,16),xlab="Index",ylab="Group values", main="Two separated groups with gap axis break", col=c(rep(2,10),rep(3,10)),ytics=c(3,5,18,20)) legend(12,6,c("Low group","High group"),pch=1,col=2:3) } \keyword{misc} plotrix/man/arctext.Rd0000755000176000001440000000445312026032412014520 0ustar ripleyusers\name{arctext} \title{Display text on a circular arc} \description{Displays a character string on the circumference of an imaginary circle on an existing plot.} \usage{ arctext(x,center=c(0,0),radius=1,start=NA,middle=pi/2,end=NA,stretch=1, clockwise=TRUE,cex=NA,...) } \alias{arctext} \arguments{ \item{x}{A character string.} \item{center}{The center of the circular arc in x/y user units.} \item{radius}{The radius of the arc in user units.} \item{start}{The starting position of the string in radians.} \item{middle}{The middle position of the string in radians.} \item{end}{The end position of the string in radians.} \item{stretch}{How much to stretch the string for appearance.} \item{clockwise}{Whether to print the string in the clockwise direction.} \item{cex}{The character expansion factor.} \item{...}{additional arguments passed to \samp{text}.} } \details{ \samp{arctext} displays a string along a circular arc, rotating each letter. This may not work on all devices, as not all graphic devices can rotate text to arbitrary angles. The output looks best on a Postscript or similar device that can rotate text without distortion. Rotated text often looks very ragged on small bitmaps. If the user passes a value for \samp{start}, this will override any value passed to \samp{middle}. If the plot area is not square, see \samp{par(pty="s")}, the arc will be somewhat elliptical. If the \samp{clockwise} argument is TRUE, the string will be displayed in a clockwise direction and the orientation of the characters will be rotated \samp{pi} radians (180 degrees). This is useful when the string is to be displayed on the bottom of the circumference. } \value{nil} \author{Jim Lemon - Thanks to Suhas Parandekar for the idea, Ted Toal for greatly improving the placement of the text and Andy South for providing the initial code for the clockwise argument.} \seealso{\link{text}} \examples{ plot(0,xlim=c(1,5),ylim=c(1,5),main="Test of arctext",xlab="",ylab="", type="n") arctext("bendy like spaghetti",center=c(3,3),col="blue") arctext("bendy like spaghetti",center=c(3,3),radius=1.5,start=pi,cex=2) arctext("bendy like spaghetti",center=c(3,3),radius=0.5, start=pi/2,stretch=1.2) arctext("bendy like spaghetti",center=c(3,3),radius=1.7,start=4*pi/3,cex=1.3, clockwise=FALSE) } \keyword{misc} plotrix/man/addtable2plot.Rd0000755000176000001440000000536112045713776015612 0ustar ripleyusers\name{addtable2plot} \alias{addtable2plot} \title{Add a table of values to a plot} \description{ Displays a table of values at a user-specified position on an existing plot} \usage{ addtable2plot(x,y=NULL,table,lwd=par("lwd"),bty="n",bg=par("bg"), cex=1,xjust=0,yjust=1,xpad=0.1,ypad=0.5,box.col=par("fg"),text.col=par("fg"), display.colnames=TRUE,display.rownames=FALSE,hlines=FALSE,vlines=FALSE, title=NULL) } \arguments{ \item{x,y}{Either x and y coordinates to locate the table or an \samp{xy.coords} object.} \item{table}{A data frame, matrix or similar object that will be displayed.} \item{lwd}{The line width for the box and horizontal dividers.} \item{bty}{Whether to draw a box around the table ("o") or not ("n").} \item{bg}{The background color for the table.} \item{cex}{Character expansion for the table.} \item{xjust,yjust}{Positioning for the table relative to \samp{x,y}.} \item{xpad,ypad}{The amount of padding around text in the cells as a proportion of the maximum width and height of the strings in each column.} \item{box.col}{The color for the box and lines.} \item{text.col}{The color for the text.} \item{display.colnames}{Whether to display the column names in the table.} \item{display.rownames}{Whether to display the row names in the table.} \item{hlines}{Whether to draw horizontal lines between each row of the table.} \item{vlines}{Whether to draw vertical lines between each column of the table.} \item{title}{Optional title placed over the table.} } \value{nil} \details{ \samp{addtable2plot} displays the values in \samp{table} at a position in user coordinates specified by \samp{x,y}. The two justification arguments, \samp{xjust} and \samp{yjust} are the same as in the \samp{legend} function, and \samp{addtable2plot} has been programmed to be as similar to \samp{legend} as possible. The defaults are those that were most popular in scientific journals at the time of programming. If \samp{bg} is a matrix of colors of the same dimensions as \samp{x}, those colors will be the backgrounds of the cells. The default is no background color. } \author{Original by John Kane, mods by Jim Lemon and Brian Diggs. Thanks to Andrija Djurovic for asking for the individual cell colors and Gabor Grothendieck for alerting me to the problem of widely varying column widths.} \seealso{\link{legend}} \examples{ testdf<-data.frame(Before=c(10,7,5,9),During=c(8,6,2,5),After=c(5,3,4,3)) rownames(testdf)<-c("Red","Green","Blue","Lightblue") barp(testdf,main="Test addtable2plot",ylab="Value", names.arg=colnames(testdf),col=2:5) # show most of the options addtable2plot(2,8,testdf,bty="o",display.rownames=TRUE,hlines=TRUE, vlines=TRUE,title="The table") } \keyword{misc} plotrix/man/add.ps.Rd0000644000176000001440000000656511747474416014251 0ustar ripleyusers\name{add.ps} \alias{add.ps} \title{ add p-values from t-tests } \description{ Adds p-values comparing the different cells at each x-axis position with a reference cell. Uses a syntax similar to \code{raw.means.plot2}. } \usage{ add.ps(data, col.id, col.offset, col.x, col.value, fun.aggregate = "mean", ref.offset = 1, prefixes, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, lty = 0, ...) } \arguments{ \item{data}{ A \code{data.frame} } \item{col.id}{ \code{character} vector specifying the id column. } \item{col.offset}{ \code{character} vector specifying the offset column. } \item{col.x}{ \code{character} vector specifying the x-axis column. } \item{col.value}{ \code{character} vector specifying the data column. } \item{fun.aggregate}{ Function or function name used for aggregating the results. Default is \code{"mean"}. } \item{ref.offset}{ Scalar \code{numeric} indicating the reference level to be tested against. The default is 1 corresponding to \code{levels(factor(d[,col.offset]))[1]}. } \item{prefixes}{ \code{character} vector of the indices for the p-values. If missing corresponds to \code{levels(factor(d.new[,col.offset]))[-ref.offset]}. } \item{alternative}{ same as in \code{\link{t.test}} } \item{mu}{ same as in \code{\link{t.test}} } \item{paired}{ same as in \code{\link{t.test}} } \item{var.equal}{ same as in \code{\link{t.test}} } \item{lty}{ line type of axis, Default is 0 (i.e., no line). } \item{\dots}{ further arguments passed to axis. } } \details{ This function computes t-tests comparing the values at each x-axis position for each condition against the reference condition at and adds the p-values to the axis. This functions uses the same syntax as \code{\link{raw.means.plot2}} and should be used in addition to it. Note that values are ordered according to the \code{col.id} so \code{paired = TRUE} should be fine. } \value{ axis is plotted. } \author{ Henrik Singmann } \seealso{ \code{\link{raw.means.plot}} as the accompanying main functions. } \examples{ \dontrun{ #The examples uses the OBrienKaiser dataset from car and needs reshape. # This extends the examples from raw.means.plot require(reshape) require(car) data(OBrienKaiser) OBKnew <- cbind(factor(1:nrow(OBrienKaiser)), OBrienKaiser) colnames(OBKnew)[1] <- "id" OBK.long <- melt(OBKnew) OBK.long[, c("measurement", "time")] <- t(vapply(strsplit(as.character(OBK.long$variable), "\\\."), "[", c("", ""))) # For this example the position at each x-axis are within-subject comparisons! raw.means.plot2(OBK.long, "id", "measurement", "gender", "value") add.ps(OBK.long, "id", "measurement", "gender", "value", paired = TRUE) #reference is "fup" raw.means.plot2(OBK.long, "id", "measurement", "gender", "value") add.ps(OBK.long, "id", "measurement", "gender", "value", ref.offset = 2, paired = TRUE) #reference is "post" # Use R's standard (i.e., Welch test) raw.means.plot2(OBK.long, "id", "treatment", "gender", "value") add.ps(OBK.long, "id", "treatment", "gender", "value", prefixes = c("p(control vs. A)", "p(control vs. B)")) # Use standard t-test raw.means.plot2(OBK.long, "id", "treatment", "gender", "value") add.ps(OBK.long, "id", "treatment", "gender", "value", var.equal = TRUE, prefixes = c("p(control vs. A)", "p(control vs. B)")) } } plotrix/man/ablineclip.Rd0000755000176000001440000000315211670357036015163 0ustar ripleyusers\name{ablineclip} \alias{ablineclip} \title{Add a straight line to a plot} \description{ As \samp{abline}, but has arguments \samp{x1,x2,y1,y2} as in \samp{clip}. } \usage{ ablineclip(a=NULL,b=NULL,h=NULL,v=NULL,reg=NULL,coef=NULL,untf=FALSE, x1=NULL,x2=NULL,y1=NULL,y2=NULL,...) } \arguments{ \item{a}{Intercept.} \item{b}{Slope.} \item{h}{the x-value(s) for vertical line(s).} \item{v}{the y-value(s) for horizontal line(s).} \item{reg}{Fitted lm object. } \item{coef}{Coefficients, typically intercept and slope.} \item{untf}{How to plot on log coordinates, see \samp{abline}.} \item{x1,x2,y1,y2}{Clipping limits, see \samp{clip}.} \item{...}{Further arguments passed to \samp{abline}.} } \details{ \samp{ablineclip} sets a new clipping region and then calls \samp{abline}. If any of the four clipping limits is NULL, the values from \samp{par("usr")} are substituted. After the call to \samp{abline}, the old clipping region is restored. In order to make \samp{clip} work, there is a call to \samp{abline} that draws a line off the plot. Multiple lines of the same type can be drawn in a single call, but the clipping region must be the same for each group of lines. Thanks to Berry Boessenkool for pointing this out. } \value{ None. Adds to the current plot. } \author{ Remko Duursma } \seealso{\link{abline}, \link{clip}} \examples{ x <- rnorm(100) y <- x + rnorm(100) lmfit <- lm(y~x) plot(x,y,xlim=c(-3.5,3.5)) ablineclip(lmfit,x1=-2,x2=2,lty=2) ablineclip(h=0,x1=-2,x2=2,lty=3,col="red") ablineclip(v=0,y1=-2.5,y2=1.5,lty=4,col="green") } \keyword{ aplot }plotrix/inst/0000755000176000001440000000000012132136377012765 5ustar ripleyusersplotrix/inst/CITATION0000755000176000001440000000057711535616063014137 0ustar ripleyuserscitHeader("To cite package 'plotrix' in publications use:") citEntry(entry="Article", year = 2006, title = "Plotrix: a package in the red light district of R", journal = "R-News", volume = "6", number = "4", pages = "8-12", author = personList(as.person("Lemon J")), textVersion = "Lemon, J. (2006) Plotrix: a package in the red light district of R. R-News, 6(4): 8-12." ) plotrix/demo/0000755000176000001440000000000012026027177012733 5ustar ripleyusersplotrix/demo/plotrix.R0000755000176000001440000003757712026027177014605 0ustar ripleyusers# The plotrix demo in roughly alphabetical order # Press to advance through the demo, # Ctrl-C (Linux) or Esc (Windows) to exit par(ask=TRUE) x <- rnorm(100) y <- x + rnorm(100) lmfit <- lm(y~x) plot(x,y,xlim=c(-3.5,3.5),main="Ablineclip") ablineclip(lmfit,x1=-2,x2=2,lty=2) ablineclip(h=0,x1=-2,x2=2,lty=3,col="red") ablineclip(v=0,y1=-2.5,y2=1.5,lty=4,col="green") testdf<-data.frame(Before=c(10,7,5),During=c(8,6,2),After=c(5,3,4)) rownames(testdf)<-c("Red","Green","Blue") barp(testdf,main="Test addtable2plot",ylab="Value", names.arg=colnames(testdf),col=2:4) addtable2plot(2,8,testdf,bty="o",display.rownames=TRUE,hlines=TRUE, title="The table") plot(0,xlim=c(1,5),ylim=c(1,5),main="Arctext",xlab="",ylab="", type="n") arctext("bendy like spaghetti",center=c(3,3),col="blue") arctext("bendy like spaghetti",center=c(3,3),radius=1.5,start=pi,cex=2) arctext("bendy like spaghetti",center=c(3,3),radius=0.5, start=pi/2,stretch=1.2) plot(3:10,main="Axis break test") # put a break at the default axis and position axis.break() axis.break(2,2.9,style="zigzag") twogrp<-c(rnorm(10)+4,rnorm(10)+20) gap.plot(twogrp,gap=c(8,16),xlab="Index",ylab="Group values", main="Two separated groups with gap axis break", col=c(rep(2,10),rep(3,10)),ytics=c(3,5,18,20)) legend(12,6,c("Low group","High group"),pch=1,col=2:3) plot(1:10*0.001,1:10*100,axes=FALSE,xlab="",ylab="",main="Axis multipliers") box() axis.mult(1,mult=0.001) axis.mult(2,mult=100) par(mar=c(5,5,4,2)) test.df<-data.frame(Age=rnorm(100,25,10), Sex=sample(c("M","F"),100,TRUE), Marital=sample(c("M","X","S","W"),100,TRUE), Employ=sample(c("FT","PT","NO"),100,TRUE)) test.col<-list(Overall="green",Employ=c("purple","orange","brown"), Marital=c("#1affd8","#caeecc","#f7b3cc","#94ebff"),Sex=c(2,4)) barNest(formula=Age~Employ+Marital+Sex,data=test.df,main="barNest", col=test.col,showall=TRUE) happyday<-data.frame(Monday=c(2.3,3.4),Tuesday=c(2.8,3.3),Wednesday=c(3.2,3.1), Thursday=c(3.6,2.8),Friday=c(4.2,2.6),Saturday=c(4.5,2.9),Sunday=c(4.1,2.8)) happylabels<-c("Utterly dashed","Rather mopey","Indifferent","Somewhat elated", "Euphoric") barp(happyday,names.arg=names(happyday),legend.lab=c("Slaves","Unemployed"), legend.pos=list(x=2,y=4.5),col=c("#ee7700","#3333ff"), main="Test of barp, staxlab and color.legend", xlab="Day of week",ylab="Happiness rating",ylim=c(1,5),staxx=TRUE,staxy=TRUE, height.at=1:5,height.lab=happylabels,cex.axis=0.9,cylindrical=TRUE, shadow=TRUE) par(mar=c(5,4,4,2)) h1<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) h2<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) h3<-table(cut(rnorm(100,4),breaks=seq(0,8,by=2))) hmat<-matrix(c(h1,h2,h3),nrow=3,byrow=TRUE) barp(hmat,names.arg=names(h1),width=0.45,col=2:4, main="Multiple histogram using barp",xlab="Bins",ylab="Frequency") legend(3.8,50,c("h1","h2","h3"),fill=2:4) x<-rnorm(10) y<-rnorm(10) plot(x,y,type="p",main="Boxed.labels") nums<-c("one","two","three","four","five","six","seven","eight","nine","ten") boxed.labels(x,y-0.1,nums) test.df<-data.frame(a=rnorm(80)+4,b=rnorm(80)+4,c=rep(LETTERS[1:4],each=20), d=rep(rep(letters[1:4],each=4),5)) bp<-brkdn.plot("a","c","d",test.df,main="Test of brkdn.plot", mct="median",md="mad",xlab="Temperature range", ylab="Cognition", xaxlab=c("10-15","16-20","21-25","25-30"),pch=1:4,lty=1:4,col=1:4,ylim=c(0,6)) legend(1,2.5,legend=c("Sydney","Gosford","Karuah","Brisbane"),pch=1:4, col=1:4,lty=1:4,xjust=0.5,yjust=0.5) educattn<-matrix(c(90.4,90.3,75.7,78.9,66,71.8,70.5,70.4,68.4,67.9, 67.2,76.1,68.1,74.7,68.5,72.4,64.3,71.2,73.1,77.8),ncol=2,byrow=TRUE) rownames(educattn)<-c("Anchorage AK","Boston MA","Chicago IL", "Houston TX","Los Angeles CA","Louisville KY","New Orleans LA", "New York NY","Philadelphia PA","Washington DC") colnames(educattn)<-c(1990,2000) bumpchart(educattn,rank=FALSE, main="Percentage high school completion by over 25s",col=rainbow(10)) # margins have been reset, so use par(xpd=TRUE) boxed.labels(1.5,seq(65,90,by=5),seq(65,90,by=5)) par(xpd=FALSE) testcp<-list("",40) for(i in 1:40) testcp[[i]]<-rnorm(sample(1:8,1)*50) segs<-get.segs(testcp) centipede.plot(segs,main="Centipede plot",vgrid=0) xy.mat<-cbind(sample(1:10,200,TRUE),sample(1:10,200,TRUE)) clusteredpoints<- cluster.overplot(xy.mat,col=rep(c("red","green"),each=100)) plot(clusteredpoints,col=clusteredpoints$col, main="Cluster overplot test") xy.mat<-cbind(sample(1:10,200,TRUE),sample(1:10,200,TRUE)) count.overplot(xy.mat,main="Count overplot test", xlab="X values",ylab="Y values") par(mar=c(7,4,4,6)) testcol<-color.gradient(c(0,1),0,c(1,0),nslices=5) col.labels<-c("Cold","Warm","Hot") color2D.matplot(matrix(rnorm(100),nrow=10),c(1,0),0,c(0,1), main="Test color2D.matplot with color.legend") color.legend(11,6,11.8,9,col.labels,testcol,gradient="y") color.legend(10.2,2,11,5,col.labels,testcol,align="rb",gradient="y") color.legend(0.5,-2,3.5,-1.2,col.labels,testcol) color.legend(7,-1.8,10,-1,col.labels,testcol,align="rb",col=testcol[c(1,3,5)]) par(mar=c(5,4,4,2)) x<-c(0,cumsum(rnorm(99))) y<-c(0,cumsum(rnorm(99))) xydist<-sqrt(x*x+y*y) plot(x,y,main="Random walk plot (color.scale.lines)",xlab="X",ylab="Y",type="n") color.scale.lines(x,y,c(1,1,0),0,c(0,1,1),colvar=xydist,lwd=2) boxed.labels(x,y,labels=1:100,border=FALSE,cex=0.5) testlen<-rnorm(24)*2+5 testpos<-0:23+rnorm(24)/4 clock24.plot(testlen[7:19],testpos[7:19], main="Test Clock24 daytime (symbols)", point.col="blue",rp.type="s",lwd=3) par(mar=c(5,4,4,2)) x<-seq(1,100) y<-sin(x/5)+x/20 clplot(x,y,main="Clplot") x<-list(runif(90,1,2),factor(sample(LETTERS,100,TRUE)),rnorm(80,mean=5)) dendroPlot(x,breaks=list(seq(1,2,by=0.1),0,0:10),nudge=c(0.03,0.3), xlab="Groups",ylab="Counts",main="Test dendroPlot") data(mtcars) mysubset<-mtcars[substr(dimnames(mtcars)[[1]],1,1)=="M",c("mpg","hp","wt","disp")] diamondplot(mysubset,name="Diamondplot") plot(1:10, asp = 1,main="Test draw.arc") draw.arc(5, 5, 1:10/10, deg2 = 1:10*10, col = "blue") draw.arc(8, 8, 1:10/10, deg2 = 1:10*10, col = 1:10) plot(1:5,seq(1,10,length=5),type="n",xlab="",ylab="",main="Test draw.circle") draw.circle(2,4,c(1,0.66,0.33),border="purple", col=c("#ff00ff","#ff77ff","#ffccff"),lty=1,lwd=1) draw.circle(2.5,8,0.6,border="red",lty=3,lwd=3) draw.circle(4,3,0.7,border="green",lty=1,lwd=1) draw.circle(3.5,7,0.8,border="blue",lty=2,lwd=2) x<-rnorm(10) y<-rnorm(10) plot(x,y,main="Find the empty space",xlab="X",ylab="Y") es<-emptyspace(x,y) boxed.labels(es,labels="Here is the\nempty space") iucn.df<-data.frame(area=c("Africa","Asia","Europe","N&C America", "S America","Oceania"),threatened=c(5994,7737,1987,4716,5097,2093)) fan.plot(iucn.df$threatened,max.span=pi, labels=paste(iucn.df$area,iucn.df$threatened,sep="-"), main="Threatened species by geographical area (fan.plot)",ticks=276) feather.plot(0.6+rnorm(8)/5,seq(0,7*pi/4,by=pi/4),1:8, main="Test of feather.plot",xlab="Time",ylab="Value") plot(1:5,type="n",main="Floating Pie test",xlab="",ylab="",axes=FALSE) box() polygon(c(0,0,5.5,5.5),c(0,3,3,0),border="#44aaff",col="#44aaff") floating.pie(1.7,3,c(2,4,4,2,8),radius=0.5, col=c("#ff0000","#80ff00","#00ffff","#44bbff","#8000ff")) floating.pie(3.1,3,c(1,4,5,2,8),radius=0.5, col=c("#ff0000","#80ff00","#00ffff","#44bbff","#8000ff")) floating.pie(4,1.5,c(3,4,6,7),radius=0.5, col=c("#ff0066","#00cc88","#44bbff","#8000ff")) draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(3.9,2.1,radius=0.04,col="white") draw.circle(4,2.3,radius=0.04,col="white") draw.circle(4.07,2.55,radius=0.04,col="white") draw.circle(4.03,2.85,radius=0.04,col="white") text(c(1.7,3.1,4),c(3.7,3.7,3.7),c("Pass","Pass","Fail")) Ymd.format<-"%Y/%m/%d" gantt.info<-list(labels= c("First task","Second task","Third task","Fourth task","Fifth task"), starts= as.POSIXct(strptime( c("2004/01/01","2004/02/02","2004/03/03","2004/05/05","2004/09/09"), format=Ymd.format)), ends= as.POSIXct(strptime( c("2004/03/03","2004/05/05","2004/05/05","2004/08/08","2004/12/12"), format=Ymd.format)), priorities=c(1,2,3,4,5)) vgridpos<-as.POSIXct(strptime(c("2004/01/01","2004/02/01","2004/03/01", "2004/04/01","2004/05/01","2004/06/01","2004/07/01","2004/08/01", "2004/09/01","2004/10/01","2004/11/01","2004/12/01"),format=Ymd.format)) vgridlab<- c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") gantt.chart(gantt.info,main="Calendar date Gantt chart (2004)", priority.legend=TRUE,vgridpos=vgridpos,vgridlab=vgridlab,hgrid=TRUE) twogrp<-c(rnorm(10)+4,rnorm(10)+20) gap.barplot(twogrp,gap=c(8,16),xlab="Index",ytics=c(3,6,17,20), ylab="Group values",main="gap.barplot") twovec<-list(vec1=c(rnorm(30),-6),vec2=c(sample(1:10,40,TRUE),20)) gap.boxplot(twovec,gap=list(top=c(12,18),bottom=c(-5,-3)), main="Test gap.boxplot") twogrp<-c(rnorm(5)+4,rnorm(5)+20,rnorm(5)+5,rnorm(5)+22) gpcol<-c(2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5) gap.plot(twogrp,gap=c(8,16),xlab="Index",ylab="Group values", main="Test gap.plot",col=gpcol) plot(0:10,type="n",axes=FALSE,main="gradient.rect") gradient.rect(1,0,3,6,reds=c(1,0), greens=c(seq(0,1,length=10),seq(1,0,length=10)), blues=c(0,1),gradient="y") gradient.rect(4,0,6,6,c(seq(0,1,length=10),rep(1,10)), c(rep(1,10),seq(1,0,length=10)),c(0,0),gradient="y") gradient.rect(7,0,9,6,col=smoothColors("red",38,"blue"),border=NA) druguse<-matrix(c(sample(c(0,1),200,TRUE), sample(c(0,1),200,TRUE), sample(c(0,1),200,TRUE), sample(c(0,1),200,TRUE)),ncol=4) colnames(druguse)<-c("Alc","Tob","THC","Amp") druglist<-makeIntersectList(druguse) intersectDiagram(druglist) testmat<-matrix(c(runif(50),sample(1:50,50),rnorm(50)+5, sin(1:50)),ncol=50,byrow=TRUE) kiteChart(testmat,varlabels=c("Uniform","Sample","Normal","Sine"), timepos=seq(1,50,by=5)) didf<-data.frame(subject=1:50,interv=rep(c("therapist","ex-drinker"),each=25), outcome=sample(c("more","less"),50,TRUE)) didf.tab<-table(didf$interv,didf$outcome) didf2<-c(74,46,200) didf3<-c(33,87,500) x<-list(didf.tab,didf2,didf3) labbecol<-list("red","green","blue") labbePlot(x,main="Ex-drinkers vs therapists", xlab="Percent reduced drinking (ex-drinkers)", ylab="Percent reduced drinking (therapists)", labels=list("A","B52","X117"),col=labbecol) l <- list(runif(10)*10,1:10,c(1,1,1,1,4,8)) multhist(l,main="Test of multhist") windagg<-matrix(c(8,0,0,0,0,0,0,0,4,6,2,1,6,3,0,4,2,8,5,3,5,2,1,1, 5,5,2,4,1,4,1,2,1,2,4,0,3,1,3,1),nrow=5,byrow=TRUE) oz.windrose(windagg,legend.pos=-26,main="Australian BoM wind rose") y<-runif(8) oldpar<-panes() boxplot(y,axes=FALSE) box() tab.title("Boxplot of y",tab.col="#88dd88") barplot(y,axes=FALSE,col=2:9) box() tab.title("Barplot of y",tab.col="#88dd88") pie(y,col=2:9) tab.title("Pie chart of y",tab.col="#88dd88") box() plot(y,xaxs="i",xlim=c(0,9),axes=FALSE,col=2:9) box() tab.title("Scatterplot of y",tab.col="#88dd88") # center the title at the left edge of the last plot mtext("Test of panes function",at=0,side=1,line=0.8,cex=1.5) par(oldpar) pieval<-c(2,4,6,8) pielabels<- c("We hate\n pies","We oppose\n pies","We don't\n care","We just love pies") pie3D(pieval,radius=0.9,labels=pielabels,explode=0.1,main="3D PIE OPINIONS") sex<-sample(c("M","F"),100,TRUE) hair<-sample(c("Blond","Black","Brown","Red"),100,TRUE) eye<-sample(c("Blue","Black","Brown","Green"),100,TRUE) charac<-data.frame(sex=sex,hair=hair,eye=eye) characlist<-makeDendrite(charac) plot.dendrite(characlist,names(charac), main="Dendrogram of sex, hair and eye color",cex=0.8) xy.pop<-c(3.2,3.5,3.6,3.6,3.5,3.5,3.9,3.7,3.9,3.5,3.2,2.8,2.2,1.8, 1.5,1.3,0.7,0.4) xx.pop<-c(3.2,3.4,3.5,3.5,3.5,3.7,4,3.8,3.9,3.6,3.2,2.5,2,1.7,1.5, 1.3,1,0.8) agelabels<-c("0-4","5-9","10-14","15-19","20-24","25-29","30-34", "35-39","40-44","45-49","50-54","55-59","60-64","65-69","70-74", "75-79","80-44","85+") mcol<-color.gradient(c(0,0,0.5,1),c(0,0,0.5,1),c(1,1,0.5,1),18) fcol<-color.gradient(c(1,1,0.5,1),c(0.5,0.5,0.5,1),c(0.5,0.5,0.5,1),18) par(mar=pyramid.plot(xy.pop,xx.pop,labels=agelabels, main="Australian population pyramid 2002",lxcol=mcol,rxcol=fcol, gap=0.5,show.values=TRUE)) posmat<-matrix(sample(2:9,30,TRUE),nrow=3) radial.plot(posmat,labels=paste("X",1:10,sep=""),rp.type="p", main="Spiderweb plot (radial.plot)",line.col=2:4,show.grid=FALSE,lwd=1:3, radial.lim=c(0,10)) x <- runif(20) y <- runif(20) revaxis(x,y,yside=4,main="Test revaxis") x <- c(0.1,0.1,0.1,0.1,0.1,0.2,0.2,0.2,0.2,0.3,0.3) y <- c( 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5 ) plot(x,y) sizeplot(x,y,main="sizeplot") cat1<-sample(c("None","Low","Medium","High"),40,TRUE) cat2<-sample(c("None","Low","Medium","High"),40,TRUE) cat3<-sample(c("None","Low","Medium","High"),40,TRUE) hcats<-data.frame(cat1,cat2,cat3) bhcol<-list(c("#ff8080","#dddd80","#80ff80","#8080ff"), c("red","green","lightblue","yellow"), c("#ffffff","#bbbbbb","#999999","#666666")) sizetree(hcats,col=bhcol,main="sizetree (hierarchical count chart)") soils.sw.percent<-data.frame( Sand=c(67,67,66,67,36,25,24,59,27,9,8,8,20, 45,50,56,34,29,39,41,94,98,97,93,96,99), Silt=c(17,16,9,8,39,48,54,27,46,70,68,68,66, 34,30,24,48,53,46,48,2,2,2,4,1,1), Clay=c(16,17,25,25,25,27,22,14,27,21,24,24, 14,21,20,20,18,18,15,11,4,0,1,3,3,0)) soils.sw.cols <- c(1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6) soils.sw.names <- c("Ardington","Astrop","Atrim", "Banbury","Beacon","Beckfoot") soil.texture.uk(soils.sw.percent, main = "Ternary Diagram for Some Soils from South West England", col.lines = "black", col.names = "black", show.grid = TRUE, col.grid = "blue", lty.grid = 2, pch = 16, cex = 1.0, col.symbols = soils.sw.cols, h1 = NA, h3 = NA, t1 = NA, t3 = NA , lwduk = 2, xpos = NA, ypos = NA, snames = NA, cexuk = 1.1) legend("topleft", legend = soils.sw.names, col = 1:max(soils.sw.cols), pch = 16, cex = 1.1, title = "Location", bty = "n") fpkids<-data.frame(Food=c("Fatty/sugary","Fruit","Starchy","Meat", "Proc.meat","Eggs","Fish","Dairy","Vegetables"), Female=c(4.21,4.22,3.98,3.57,3.55,3.46,3.34,3.26,3.13), Male=c(4.35,4.13,4.02,3.9,3.81,3.64,3.45,3.27,2.96)) plot(rep(1,9),fpkids$Female,xlim=c(0.8,2.2), ylim=range(c(fpkids$Female,fpkids$Male)),xlab="Sex",xaxt="n", ylab="Mean preference rating",main="Children's food preferences by sex", col="red") axis(1,at=1:2,labels=c("Female","Male")) points(rep(2,9),fpkids$Male,col="blue",pch=2) spread.labels(rep(1:2,each=9),c(fpkids$Female,fpkids$Male), fpkids$Food,between=TRUE,linecol=c("red","blue")) testx<-matrix(abs(rnorm(100)),nrow=10) stackpoly(matrix(cumsum(testx),nrow=10),main="Test Stackpoly I", xaxlab=c("One","Two","Three","Four","Five", "Six","Seven","Eight","Nine","Ten"),border="black",staxx=TRUE) sample_size<-c(500,-72,428,-94,334,-45,289) totals<-c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE) labels<-c("Contact list","Uncontactable","","Declined","","Ineligible", "Final sample") staircase.plot(sample_size,totals,labels, main="Acquisition of the sample (staircase.plot)", total.col="gray",inc.col=2:4,bg.col="#eeeebb",direction="s") x<-rnorm(20) y<-rnorm(20) xlim<-range(x) xspace<-(xlim[2]-xlim[1])/20 xlim<-c(xlim[1]-xspace,xlim[2]+xspace) ylim<-range(y) yspace<-(ylim[2]-ylim[1])/20 ylim<-c(ylim[1]-yspace,ylim[2]+yspace) plotlabels<- c("one","two","three","four","five","six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen", "eighteen","nineteen","twenty") plot(x=x,y=y,xlim=xlim,ylim=ylim,main="Test thigmophobe.labels") thigmophobe.labels(x,y,plotlabels,col=c(2:6,8:12)) data(soils) triax.retval<-triax.plot(soils[1:6,],main="Test triax.plot", show.grid=TRUE,show.legend=TRUE,col.symbols=1:6,pch=4) par(triax.retval$oldpar) twoord.plot(2:10,seq(3,7,by=0.5)+rnorm(9), 1:15,rev(60:74)+rnorm(15),xlab="Sequence", ylab="Ascending values",rylab="Descending values") tab.title("Test of twoord.plot and tab.title",tab.col="yellow",radius=0.5) o<-matrix(rep(pi*seq(0.1,0.8,by=0.1),7),ncol=8,byrow=TRUE) m<-matrix(rnorm(56)+4,ncol=8,byrow=TRUE) plot(0,xlim=c(0.7,8.3),ylim=c(0.7,7.3),type="n", main="Test vector.field with lengthKey") vectorField(o,m,vecspec="rad") lengthKey(0.3,-0.5,c(0,5,10),0.24) zoomInPlot(rnorm(100),rnorm(100),rxlim=c(-1,1),rylim=c(-1,1), zoomtitle="Zoom In Plot",titlepos=-1.5) readline("End of demo, press ") par(ask=FALSE) dev.off() plotrix/demo/00Index0000755000176000001440000000005011146502204014052 0ustar ripleyusersplotrix demo of many plotrix functions plotrix/data/0000755000176000001440000000000011661141175012717 5ustar ripleyusersplotrix/data/soils.rda0000755000176000001440000000311012132136377014540 0ustar ripleyusers]kh\UoM(GVKZdi}oݽ{w7IvR$WP"X~A( R)/"*RY؝9so93go+65M:gqGH[uEr}sֹ2OUm-7qƵ$u7ao~dy i^xR8^W+.R M;T{$-"n|qHf jax kkNz!7¾io` !b<v9ҧ=x[ 7+}|9O>VD浓*| kUcUe\V߮=גq8sS"K/9vB^uUQ?ygH`}=YT'Ô81M?cJ?|u._oRA&Nor˪TǛ=- e.?T~;G(/[e c4y+{mw주4>9[X({?#c[Dط4?Nq[{?#Wi^v81[9L?28,Gߣx.kƜG}{;/ЗFP%S?/c_Ϣ_!vʟF_c%$x]յ*Cי?C},buub8o+SwuB4?`0qya~_1z+S[duHc@VvsWa2+|㞫i0lpOcg++y!n ~uS㦮P}nF]`ГσF?{/:5lc}B{(. .>Q/Їud/$@9p8oã'K#[A0pdqy& '{')—D/2-~'E7w]s. 9w{$<tV VLV,VlVV\V8 -Ϗ s0?boc}χfcr]!s k.o8 # T?'25)?z2 xiN'pڗcOXe|xؗMos2}- _˶3 WıBaՄK696S\ O>5G'x[[=_pR%pok".lܓ2Q {b]|p|gBOSlHP;2]y [Zc&d8S2Fi\&$GS(J\\qd!W- P^^bN*WێSsItn-z#Ckdk J~WήKQ2/-~VB?$Tm߮]AhؽKZ}Y+$];jZ:HFtL~XfLܒt9 dir.breaks[dir] && dir < ndir) dir<-dir+1 if(winddir[i] > dir.breaks[ndir]) dir<-1 speed<-1 while(windspeed[i] > speed.breaks[speed] && speed < nspeeds) speed<-speed+1 windagg[speed,dir]<-windagg[speed,dir]+1 } windagg<-100*windagg/sum(windagg) return(windagg) } oz.windrose.legend<-function(maxpct=20,scale.factor=30, speed.col=c("#dab286","#fe9a66","#ce6733","#986434"), speed.width=NA,legend.pos=NA) { wdnames<-c("E","NE","N","NW","W","SW","S","SE") if(is.na(speed.width[1])) speed.width<-maxpct*1:4/100 if(is.na(legend.pos[1])) legend.pos<-maxpct*1.25 draw.circle(-maxpct/2,legend.pos,maxpct/20) angles<-seq(0,7*pi/4,by=pi/4) for(i in 1:8) { x<-cos(angles[i])*c(maxpct/20,maxpct/16,maxpct/10)-maxpct/2 y<-sin(angles[i])*c(maxpct/20,maxpct/16,maxpct/10)+legend.pos segments(x[1],y[1],x[2],y[2]) text(x[3],y[3],wdnames[i],cex=0.7) } wsnames<-c("1-10","10-20","20-30","30+") draw.circle(-maxpct/30,legend.pos,maxpct/30) for(i in 1:length(speed.col)) { x<-c(i-1,i)*maxpct/4 y<-c(legend.pos-speed.width[i],legend.pos+speed.width[i]) polygon(c(x[1],x[1],x[2],x[2]),c(y[1],y[2],y[2],y[1]),col=speed.col[i]) text((x[1]+x[2])/2,legend.pos-maxpct/15,wsnames[i],cex=0.7) } text(-maxpct/30,legend.pos+maxpct/10,"Calm") text(maxpct/2,legend.pos+maxpct/10,"km/h") text(maxpct/2,legend.pos-maxpct/8,paste("Scale factor = ",scale.factor,"%",sep="")) } oz.windrose<-function(windagg,maxpct=20,wrmar=c(4,5,6,5), scale.factor=30,speed.col=c("#dab286","#fe9a66","#ce6733","#986434"), speed.width=NA,show.legend=TRUE,legend.pos=NA,...) { if(is.na(speed.width[1])) speed.width<-maxpct*1:4/100 if(is.na(legend.pos[1])) legend.pos<-maxpct*1.25 oldmar<-par("mar") par(mar=wrmar,xpd=TRUE) plot(0,xlim=c(-maxpct,maxpct),ylim=c(-maxpct,maxpct),type="n", axes=FALSE,xlab="",ylab="",...) winddim<-dim(windagg) calm.radius<-sum(windagg[1,])/winddim[2] rad<-10 while(rad<=maxpct) { draw.circle(0,0,rad+calm.radius,border="gray") boxed.labels(rad+calm.radius,maxpct/10,paste(rad,"%",sep=""),ypad=0.7,border=FALSE) rad<-rad+10 } draw.circle(0,0,calm.radius,border="gray") angle.inc<--2*pi/winddim[2] angles<-seq(5*pi/2,pi/2+angle.inc,by=angle.inc) descpct<-order(colSums(windagg),decreasing=TRUE) for(i in descpct) { next.radius<-calm.radius for(j in 2:winddim[1]) { xinner<-cos(angles[i])*next.radius xouter<-cos(angles[i])*(windagg[j,i]+next.radius) yinner<-sin(angles[i])*next.radius youter<-sin(angles[i])*(windagg[j,i]+next.radius) next.radius<-sqrt(xouter*xouter+youter*youter) # find the four points for each rectangle xoffset<-cos(angles[i]-pi/2)*speed.width[j-1] yoffset<-sin(angles[i]-pi/2)*speed.width[j-1] polygon(c(xinner-xoffset,xinner+xoffset,xouter+xoffset,xouter-xoffset), c(yinner-yoffset,yinner+yoffset,youter+yoffset,youter-yoffset), col=speed.col[j-1]) } } text(-maxpct,maxpct/4,paste("Calm ",round(sum(windagg[1,]),1),"%",sep=""),col="blue") if(show.legend) oz.windrose.legend(maxpct=maxpct,scale.factor=scale.factor,speed.col=speed.col, speed.width=speed.width,legend.pos=legend.pos) par(oldmar) } plotrix/R/weighted.hist.R0000755000176000001440000000404111774767323015120 0ustar ripleyusersget.breaks<-function(x,breaks) { # if a break computing function name is passed if(is.character(breaks)) nbreaks<-do.call(paste("nclass",breaks,sep=".",collapse=""),list(x)) # if breaks is numeric if(is.numeric(breaks)) { # if just the number of breaks is passed if(length(breaks) == 1) { nbreaks<-breaks } # otherwise assume that breaks specifies the breakpoints else return(breaks) } breakinc<-diff(range(x))/nbreaks breaks<-c(min(x),rep(breakinc,nbreaks)) breaks<-cumsum(breaks) return(breaks) } weighted.hist<-function(x,w,breaks="Sturges",col=NULL,plot=TRUE, freq=TRUE,ylim=NA,ylab=NULL,xaxis=TRUE,...) { if(missing(x)) stop("Usage: weighted.hist(x,...) vector of values x required") if(missing(w)) w<-rep(1,length(x)) breaks<-get.breaks(x,breaks) width<-diff(breaks) diffx<-diff(range(x)) equidist<-sum(width-width[1]) < diffx/1000 nbreaks<-length(breaks)-1 # make sure that the last break is greater than the maximum value lastbreak<-breaks[nbreaks+1] breaks[nbreaks+1]<-breaks[nbreaks+1]+diffx/1000 if(diff(range(breaks)) < diffx) warning("Not all values will be included in the histogram") counts<-rep(0,nbreaks) for(bin in 1:nbreaks) counts[bin]<-sum(w[x >= breaks[bin] & x < breaks[bin+1]]) density<-counts/sum(counts) if(freq) { if(is.null(ylab)) ylab<-"Frequency" heights<-counts if(!equidist) warning("Areas will not relate to frequencies") } else { if(!equidist) { heights<-density*mean(width)/width heights<-heights/sum(heights) } else heights<-density if(is.null(ylab)) ylab<-"Density" } if(plot) { if(is.null(col)) col<-par("bg") if(is.na(ylim)) ylim<-c(0,1.1*max(heights,na.rm=TRUE)) mids<-barplot(heights,width=width,col=col,space=0,ylim=ylim,ylab=ylab,...) tickpos<-c(mids-width/2,mids[length(mids)]+width[length(width)]/2) if(xaxis) axis(1,at=tickpos,labels=signif(c(breaks[1:nbreaks],lastbreak),3)) } else mids<-breaks[-length(breaks)]+width/2 invisible(list(breaks=breaks,counts=counts,density=density, mids=mids,xname=deparse(substitute(x)),equidist=equidist)) } plotrix/R/vectorField.R0000755000176000001440000000204211770564230014603 0ustar ripleyusers# Arguments: # u,v - the x (longitude) and y (latitude) offsets # OR orientation and magnitude # xpos,ypos - the centers of the vectors # scale - the longest arrow as a proportion of the cell size # headspan - the extent of the arrowhead as a proportion of cell size # this function doesn't assume a 1:1 aspect ratio vectorField<-function(u,v,xpos=NA,ypos=NA,scale=1,headspan=0.1, vecspec=c("lonlat","rad","deg"),col=par("fg")) { udim<-dim(u) if(is.na(xpos[1])) xpos<-col(u) if(is.na(ypos[1])) ypos<-udim[1]-row(u)+1 # if long/lat not specified if(match(vecspec[1],"lonlat",0) == 0) { # convert the degrees to radians if necessary if(match(vecspec[1],"deg",0)) u<-pi*u/180. mag<-v tempu<-v*cos(u) v<-v*sin(u) u<-tempu } else mag<-sqrt(u*u+v*v) if(is.null(dim(xpos))) maxmag<-0.5*max(diff(xpos))/max(mag) else maxmag<-0.5*max(diff(xpos[1,]))/max(mag) u2<-u*scale*maxmag v2<-v*scale*maxmag if(is.null(udim)) length=headspan else length<-headspan*par("pin")[1]/udim[2] arrows(xpos-u2,ypos-v2,xpos+u2,ypos+v2,length=length,col=col) } plotrix/R/twoord.stackplot.R0000755000176000001440000001124211631655264015664 0ustar ripleyusers twoord.stackplot <- function(lx, rx, ldata, rdata, lcol, rcol, ltype, rtype, border, rylab, lylab, xlab, ..., incrylim=NULL, halfwidth=0.4, leftfront=FALSE, mar = c(5, 4, 4, 4)) { ltype <- sapply(ltype, function(x) match.arg(x, c("p","l","b","c","o","bar"))) rtype <- sapply(rtype, function(x) match.arg(x, c("p","l","b","c","o","bar"))) incrylim <- ifelse(is.null(incrylim), 0, as.numeric(incrylim)) #convert to matrix if(is.vector(ldata)) ldata <- as.matrix(ldata) if(is.vector(rdata)) rdata <- as.matrix(rdata) #some default parameters if(missing(border)) border <- "grey80" if(missing(xlab)) xlab <- "x" if(missing(rylab)) rylab <- "right y values" if(missing(lylab)) lylab <- "left y values" if(missing(lcol)) lcol <- palette()[1:NCOL(ldata)] if(missing(rcol)) rcol <- palette()[1:NCOL(rdata)] xlimits <- range(lx, rx) #assume line plot for the left data, and barplot for the right data oldmar <- par("mar") par(mar = mar) if(leftfront) { twoord.stackplot(rx, lx, rdata, ldata, rcol, lcol, rtype, ltype, border, lylab, rylab, xlab, ..., incrylim=NULL, halfwidth=0.4, leftfront=FALSE, mar = c(5, 4, 4, 4)) return(invisible()) } #------------------------------------------------------------------------ #left y-axis plot if(NCOL(ldata) > 1) { lcol <- rep(lcol, length=NCOL(ldata)) ltype <- rep(ltype, length=NCOL(ldata)) } if(any(ltype == "bar")) { #------------------ lylimits <- range(ifelse(ldata <0, ldata, 0), rowSums(ldata)) lylimits[1] <- ifelse(lylimits[1] > 0, lylimits[1]*(1-incrylim), lylimits[1]*(1+incrylim)) lylimits[2] <- ifelse(lylimits[2] > 0, lylimits[2]*(1+incrylim), lylimits[2]*(1-incrylim)) plot(0, type = "n", axes = FALSE, xlim = xlimits, ylim = lylimits, ylab="", xlab=xlab, ...) xbottom <- par("usr")[1] xylim <- par("usr") ly <- ldata[,1] rect(lx-halfwidth, ifelse(ly < 0, ly, xbottom), lx+halfwidth, ifelse(ly > 0, ly, 0), col=lcol[1], border=border, ...) if(NCOL(ldata) > 1) for(i in 2:NCOL(ldata)) { ly <- ldata[,i] rect(lx-halfwidth, ifelse(ly < 0, ly, xbottom)+ldata[,i-1], lx+halfwidth, ifelse(ly > 0, ly, 0)+ldata[,i-1], col=lcol[i], border=border, ...) } }else { #------------------ lylimits <- range(ldata) lylimits[1] <- ifelse(lylimits[1] > 0, lylimits[1]*(1-incrylim), lylimits[1]*(1+incrylim)) lylimits[2] <- ifelse(lylimits[2] > 0, lylimits[2]*(1+incrylim), lylimits[2]*(1-incrylim)) plot(lx, ldata[, 1], xlim=xlimits, ylim=lylimits, col=lcol[1], type=ltype[1], axes=FALSE, ylab="", xlab=xlab, ...) if(NCOL(ldata) > 1) for(i in 2:NCOL(ldata)) lines(lx, ldata[, i], col=lcol[i], type=ltype[i], ...) } xylim <- par("usr") mtext(lylab, 2, 2, col = lcol[1]) axis(1) #x axis axat <- axis(2, col=lcol[1], labels=FALSE) #left y axis abline(v=xylim[1], col=lcol[1]) mtext(axat, 2, 1, at = axat, col = lcol[1]) box() #------------------------------------------------------------------------ #right y-axis plot par(new=TRUE) if(NCOL(rdata) > 1) { rcol <- rep(rcol, length=NCOL(rdata)) rtype <- rep(rtype, length=NCOL(rdata)) } if(any(rtype == "bar")) { #------------------ rylimits <- range(ifelse(rdata <0, rdata, 0), rowSums(rdata)) rylimits[1] <- ifelse(rylimits[1] > 0, rylimits[1]*(1-incrylim), rylimits[1]*(1+incrylim)) rylimits[2] <- ifelse(rylimits[2] > 0, rylimits[2]*(1+incrylim), rylimits[2]*(1-incrylim)) ry <- rdata[,1] plot(0, type = "n", axes = FALSE, xlim = xlimits, ylim = rylimits, ylab="", xlab="", ...) xbottom <- par("usr")[1] xylim <- par("usr") rect(rx-halfwidth, ifelse(ry < 0, ry, xbottom), rx+halfwidth, ifelse(ry > 0, ry, 0), col=rcol[1], border=border, ...) if(NCOL(rdata) > 1) for(i in 2:NCOL(rdata)) { ry <- rdata[,i] rect(rx-halfwidth, ifelse(ry < 0, ry, xbottom)+rdata[,i-1], rx+halfwidth, ifelse(ry > 0, ry, 0)+rdata[,i-1], col=rcol[i], border=border, ...) } }else { #------------------ rylimits <- range(rdata) rylimits[1] <- ifelse(rylimits[1] > 0, rylimits[1]*(1-incrylim), rylimits[1]*(1+incrylim)) rylimits[2] <- ifelse(rylimits[2] > 0, rylimits[2]*(1+incrylim), rylimits[2]*(1-incrylim)) plot(rx, rdata[, 1], xlim=xlimits, ylim=rylimits, col=rcol[1], type=rtype[1], axes=FALSE, ylab="", xlab="", ...) if(NCOL(rdata) > 1) for(i in 2:NCOL(rdata)) lines(rx, rdata[, i], col=rcol[i], type=rtype[i], ...) } axat <- axis(4, col=rcol[1], labels=FALSE) #right y axis abline(v=xylim[1], col=rcol[1]) mtext(axat, 4, 1, at = axat, col = rcol[1]) mtext(rylab, 4, 2, col = rcol[1]) par(mar = oldmar) } plotrix/R/twoord.plot.R0000755000176000001440000000450211671626374014643 0ustar ripleyuserstwoord.plot<-function (lx,ly,rx,ry,data=NULL,xlim=NULL,lylim=NULL, rylim=NULL,mar=c(5,4,4,4),lcol=1,rcol=2,xlab="",ylab="",rylab="",lpch=1, rpch=2,type="b",xtickpos=NULL,xticklab=NULL,halfwidth=0.4,axislab.cex=1,...) { if(!is.null(data)) { ly<-data[ly] ry<-data[ry] if(missing(lx)) lx<-1:length(ly) else lx<-data[lx] if(missing(rx)) rx <- 1:length(ry) else rx<-data[rx] } if(missing(ry)) { if(missing(rx)) { rx<-1:length(ly) ry<-ly ly<-lx lx<-1:length(ly) } else { ry<-rx rx<-1:length(ry) } } oldmar<-par("mar") par(mar=mar) if(is.null(xlim)) xlim<-range(c(lx, rx)) if(missing(lx)) lx<-1:length(ly) if(is.null(lylim)) { lylim<-range(ly,na.rm=TRUE) lyspan<-diff(lylim) lylim[2]<-lylim[2]+lyspan*0.04 if(lylim[1] < 0) lylim[1]<-lylim[1]-lyspan*0.04 } if(length(type) < 2) type<-rep(type,2) if(match(type[1],"bar",0)) { plot(0,type="n",xlab=xlab,ylab="",yaxs="i",axes=FALSE,xlim=xlim,ylim=lylim,...) ybottom<-par("usr")[3] if(lylim[1] < 0) abline(h=0,lty=2) rect(lx-halfwidth,ifelse(ly<0,ly,ybottom),lx+halfwidth,ifelse(ly>0,ly,0), col=lcol) } else plot(lx,ly,xlim=xlim,ylim=lylim,xlab=xlab,ylab="",yaxs="i",col=lcol,pch=lpch, type=type[1],axes=FALSE,...) xylim<-par("usr") mtext(ylab,2,2,col=lcol,cex=axislab.cex) box() if(is.null(xticklab)) axis(1,cex=axislab.cex) else { if(is.null(xtickpos)) xtickpos<-1:length(xticklab) axis(1,at=xtickpos,labels=xticklab,cex=axislab.cex) } axat<-axis(2,col=ifelse(is.na(lcol),1,lcol),labels=FALSE) abline(v=xylim[1],col=lcol) mtext(axat,2,1,at=axat,col=lcol,cex=axislab.cex) par(new=TRUE) if(is.null(rylim)) { rylim<-range(ry,na.rm=TRUE) ryspan<-diff(rylim) rylim[2]<-rylim[2]+ryspan*0.04 if(rylim[1] < 0) rylim[1]<-rylim[1]-ryspan*0.04 } if(match(type[2],"bar",0)) { plot(0,type="n",xlab=xlab,ylab="",yaxs="i",axes=FALSE,xlim=xlim,ylim=rylim,...) ybottom<-par("usr")[3] if(rylim[1] < 0) abline("h",0) rect(rx-halfwidth,ifelse(ry < 0,ry,ybottom),rx+halfwidth,ifelse(ry > 0,ry,0), col=rcol) } else plot(rx,ry,xlim=xlim,ylim=rylim,xlab="",ylab="",yaxs="i",col=rcol,pch=rpch, type=type[2],axes=FALSE,...) axat<-axis(4,col=ifelse(is.na(rcol),1,rcol),labels=FALSE) abline(v=xylim[2],col=rcol) mtext(axat,4,1,at=axat,col=rcol,cex=axislab.cex) mtext(rylab,4,2,col=rcol,cex=axislab.cex) par(mar=oldmar,new=FALSE) } plotrix/R/triax.R0000755000176000001440000001707311503625116013471 0ustar ripleyusersget.triprop<-function(use.percentages=FALSE,cnames=c("1st","2nd","3rd")) { cat("Enter the label and ") cat(ifelse(use.percentages,"percentages ","proportions ")) cat("of",cnames[1],cnames[2],"and",cnames[3],"for each observation.\n") cat("Enter a blank observation label to end.\n") nextlabel<-"dummy" nextprop<-0 proplabels<-NA prop1<-NA prop2<-NA prop3<-NA nprop<-0 totprop<-ifelse(use.percentages,100,1) tolerance<-ifelse(use.percentages,1,0.01) while(nchar(nextlabel)) { nextlabel<-readline("Observation label - ") if(nchar(nextlabel)) { if(is.na(proplabels[1])) proplabels<-nextlabel else proplabels<-c(proplabels,nextlabel) cat(cnames[1],"- ") nextprop<-as.numeric(readline()) if(is.na(prop1[1])) prop1<-nextprop else prop1<-c(prop1,nextprop) cat(cnames[2],"- ") nextprop<-as.numeric(readline()) if(is.na(prop2[1])) prop2<-nextprop else prop2<-c(prop2,nextprop) cat(cnames[3],"- ") nextprop<-as.numeric(readline()) if(is.na(prop3[1])) prop3<-nextprop else prop3<-c(prop3,nextprop) nprop<-nprop+1 } sumprop<-prop1[nprop]+prop2[nprop]+prop3[nprop] if(abs(totprop-sumprop) > tolerance) cat("Warning - sum not equal to",totprop,"\n") } triprop<-cbind(prop1,prop2,prop3) rownames(triprop)<-proplabels colnames(triprop)<-cnames return(triprop) } triax.abline<-function(b=NULL,r=NULL,l=NULL,col=par("col"),lty=par("lty"), cc.axes=FALSE) { sin60<-sin(pi/3) if(!is.null(b)) { if(any(b>1)) b<-b/100 if(cc.axes) { bx2<-b+0.5*(1-b) by2<-sin60*(1-b) segments(b,0,bx2,by2,col=col,lty=lty) } else { bx2<-0.5*(1-b) by2<-sin60*(1-b) segments(1-b,0,bx2,by2,col=col,lty=lty) } } if(!is.null(r)) { if(any(r>1)) r<-r/100 if(cc.axes) { rx1<-0.5*r ry1<-sin60*r rx2<-1-r*0.5 segments(rx1,ry1,rx2,ry1,col=col,lty=lty) } else { rx1<-0.5*(r+1) ry1<-sin60*(1-r) rx2<-1-r segments(rx1,ry1,r,0,col=col,lty=lty) } } if(!is.null(l)) { if(any(l>1)) l<-l/100 if(cc.axes) { lx1<-0.5-l*0.5 lx2<-1-l ly<-sin60*(1-l) segments(lx1,ly,lx2,0,col=col,lty=lty) } else { lx1<-l*0.5 ly<-l*sin60 segments(lx1,ly,1-lx1,ly,col=col,lty=lty) } } } triax.points<-function(x,show.legend=FALSE,label.points=FALSE, point.labels=NULL,col.symbols=par("fg"),pch=par("pch"), bg.symbols=par("bg"),cc.axes=FALSE,...) { if(dev.cur() == 1) stop("Cannot add points unless the triax.frame has been drawn") if(missing(x)) stop("Usage: triax.points(x,...)\n\twhere x is a 3 column array of proportions or percentages") if(!is.matrix(x) && !is.data.frame(x)) stop("x must be a matrix or data frame with at least 3 columns and one row.") if(any(x > 1) || any(x < 0)) { if(any(x < 0)) stop("All proportions must be between zero and one.") if(any(x > 100)) stop("All percentages must be between zero and 100.") # convert percentages to proportions x<-x/100 } if(any(abs(rowSums(x)-1) > 0.01)) warning("At least one set of proportions does not equal one.") sin60<-sin(pi/3) if(cc.axes) { ypos<-x[,3]*sin60 xpos<-x[,1]+x[,3]*0.5 } else { ypos<-x[,3]*sin60 xpos<-1-(x[,1]+x[,3]*0.5) } nobs<-dim(x)[1] points(x=xpos,y=ypos,pch=pch,col=col.symbols,bg=bg.symbols,type="p",...) if(is.null(point.labels)) point.labels<-rownames(x) if(label.points) thigmophobe.labels(xpos,ypos,point.labels) if(show.legend) { legend(0.2,0.7,legend=point.labels,pch=pch,col=col.symbols, xjust=1,yjust=0) } invisible(list(x=xpos,y=ypos)) } triax.frame<-function(at=seq(0.1,0.9,by=0.1),axis.labels=NULL, tick.labels=NULL,col.axis="black",cex.axis=1,cex.ticks=1, align.labels=TRUE,show.grid=FALSE,col.grid="gray",lty.grid=par("lty"), cc.axes=FALSE) { sin60<-sin(pi/3) # bottom ticks bx1<-at bx2<-bx1+0.01-0.02*cc.axes by1<-rep(0,9) if(cc.axes) by2<-rep(-0.02*sin(2*pi/3),9) else by2<-rep(-0.02*sin60,9) # left ticks ly1<-at*sin60 lx1<-bx1*0.5 lx2<-lx1-0.02+0.013*cc.axes if(cc.axes) ly2<-ly1+rep(0.014*sin60,9) else ly2<-ly1 # right ticks rx1<-at*0.5+0.5 rx2<-rx1+0.01 ry1<-rev(ly1) if(cc.axes) ry2<-ry1 else ry2<-rev(ly2)+0.02*sin60 if(show.grid) { par(fg=col.grid) segments(bx1,by1,lx1,ly1,lty=lty.grid) segments(lx1,ly1,rev(rx1),rev(ry1),lty=lty.grid) segments(rx1,ry1,bx1,by1,lty=lty.grid) } par(fg=col.axis,xpd=TRUE) if(is.null(tick.labels)) { if(cc.axes) tick.labels<-list(l=rev(at),r=rev(at),b=rev(at)) else tick.labels<-list(l=at,r=at,b=at) } else { if(cc.axes) { tick.labels$l<-rev(tick.labels$l) tick.labels$r<-rev(tick.labels$r) tick.labels$b<-rev(tick.labels$b) } } # left axis label if(align.labels) par(srt=60) text(0.13,0.5,axis.labels[3-cc.axes],adj=0.5,cex=cex.axis) # left axis tick labels if(cc.axes) { par(srt=300) xoffset<-0.02 yoffset<-0.04 } else { par(srt=0) xoffset<-0.05 yoffset<-0 } text(lx1-xoffset,ly1+yoffset,tick.labels$l,cex=cex.ticks) # right axis label if(align.labels) { par(srt=300) label.adj<-0.5 } else { par(srt=0) label.adj<-0 } text(0.86,0.52,axis.labels[2+cc.axes],adj=label.adj,cex=cex.axis) # right axis tick labels if(cc.axes) { par(srt=0) xoffset<-0.033 yoffset<-0.005 } else { par(srt=60) xoffset<-0.015 yoffset<-0.045 } text(rx2+xoffset,ry1+yoffset,tick.labels$r,cex=cex.ticks) # bottom axis tick labels if(cc.axes) { par(srt=60) xoffset<- -0.03 } else { par(srt=300) xoffset<-0.03 } text(bx1+xoffset,by1-0.05,rev(tick.labels$b),cex=cex.ticks) # bottom axis label par(srt=0) text(0.5,-0.14,axis.labels[1],cex=cex.axis) # draw the triangle and ticks x1<-c(0,0,0.5) x2<-c(1,0.5,1) y1<-c(0,0,sin60) y2<-c(0,sin60,0) par(fg=col.axis) segments(x1,y1,x2,y2) # bottom ticks segments(bx1,by1,bx2,by2) # left ticks segments(lx1,ly1,lx2,ly2) # right ticks segments(rx1,ry1,rx2,ry2) } triax.fill<-function(col) { nrows<-length(col) sin60<-sin(pi/3) rowlen<-1 xinc<-0.5/nrows yinc<-sin60/nrows for(trirow in 1:nrows) { startx<-0.5-xinc*(trirow-1) starty<-sin60-trirow*yinc dir<-1 for(triangle in 1:rowlen) { polygon(c(startx-xinc,startx,startx+xinc), c(starty,starty+yinc*dir,starty),border=NA, col=col[[trirow]][triangle]) startx<-startx+xinc starty<-starty+yinc*dir dir<--dir } rowlen<-rowlen+2 } } triax.plot<-function (x=NULL,main="",at=seq(0.1,0.9,by=0.1), axis.labels=NULL,tick.labels=NULL,col.axis="black", cex.axis=1,cex.ticks=1,align.labels=TRUE,show.grid=FALSE, col.grid="gray",lty.grid=par("lty"),cc.axes=FALSE, show.legend=FALSE,label.points=FALSE,point.labels=NULL, col.symbols="black",pch=par("pch"),mar=c(5,2,4,2),no.add=TRUE,...) { oldpar<-par("fg","pty","mar","srt","xpd") par(xpd=TRUE) if(is.null(axis.labels)) axis.labels<-colnames(x)[1:3] par(pty="s",mar=mar) plot(0.5,type="n",axes=FALSE,xlim=c(0,1),ylim=c(0,1),main=main, xlab="",ylab="") triax.frame(at=at,axis.labels=axis.labels, tick.labels=tick.labels,col.axis=col.axis,cex.axis=cex.axis, cex.ticks=cex.ticks,align.labels=align.labels,show.grid=show.grid, col.grid=col.grid,lty.grid=lty.grid,cc.axes=cc.axes) if(is.null(x)) xypos <- NULL else xypos<-triax.points(x,show.legend=show.legend, label.points=label.points,point.labels=point.labels, col.symbols=col.symbols,pch=pch,cc.axes=cc.axes,...) if(no.add) par(oldpar) invisible(list(xypos=xypos,oldpar=oldpar)) } plotrix/R/thigmophobe.R0000755000176000001440000000512511573377337014662 0ustar ripleyusers# thigmophobe returns the direction (as 1|2|3|4 - see pos= in the text function) # _away_ from the nearest point where x and y are vectors of 2D coordinates thigmophobe<-function(x,y) { # if x has at least two columns, split it if(missing(y)) { if(is.list(x) && length(x) >= 2) { y<-x[[2]] x<-x[[1]] } else { if(is.matrix(x) && dim(x)[2] >= 2) { y<-x[,2] x<-x[,1] } else stop("if y is missing, x must be a list with at least 2 columns") } } if(is.array(x)) x<-as.numeric(x) if(is.array(y)) y<-as.numeric(y) # get the current upper and lower limits of the plot plot.span<-par("usr") x.span<-plot.span[2] - plot.span[1] y.span<-plot.span[4] - plot.span[3] # if either axis is logarithmic, transform the values into logarithms if(par("xlog")) x<-log(x) if(par("ylog")) y<-log(y) # scale the values to the plot span # this avoids the numerically larger # axis dominating the distance measure x<-x/x.span y<-y/y.span # trash any names that may be attached to x or y names(x)<-names(y)<-NULL # get the distance matrix as a full matrix xy.dist<-as.matrix(dist(cbind(x,y))) lenx<-length(x) nearest.index<-rep(0,lenx) for(index in 1:lenx) nearest.index[index]<-as.numeric(names(which.min(xy.dist[-index,index]))) # get the x and y differences for each point to the nearest point xdiff<-x - x[nearest.index] ydiff<-y - y[nearest.index] # first set the east/west direction dir.ew<-ifelse(xdiff > 0,4,2) # now do the north/south dir.ns<-ifelse(ydiff > 0,3,1) dir.away<-ifelse(abs(xdiff)>abs(ydiff),dir.ew,dir.ns) # set any congruent points to N/S labels or they'll overprint for(i in 1:lenx) { if(!xdiff[i] & !ydiff[i]) dir.away[c(i,nearest.index[i])]<-c(1,3) } return(dir.away) } # thigmophobe.labels positions labels at points so that they # are most distant from the nearest other point, where the # points are described as x and y coordinates. thigmophobe.labels<-function(x,y,labels=NULL,text.pos=NULL,...) { if(missing(x)) stop("Usage: thigmophobe.labels(x,y,labels=1:length(x))") lenx<-length(x) # if x has at least two columns, split it if(missing(y)) { if(is.list(x) && lenx >= 2) { y<-x[[2]] x<-x[[1]] } else stop("if y is missing, x must be a list with at least 2 elements") } # check for NA or NaN validxy<-!(is.na(x) | is.na(y)) if(is.null(labels)) labels<-1:lenx if(is.null(text.pos)) { if(lenx > 1) text.pos<-thigmophobe(x[validxy],y[validxy]) else text.pos<-3 } # allow labels to extend beyond the plot area par(xpd=TRUE) text(x[validxy],y[validxy],labels[validxy],pos=text.pos,...) # restore the clipping par(xpd=FALSE) } plotrix/R/textbox.R0000755000176000001440000000523712005141627014034 0ustar ripleyusers####################################################################################### # Fix problems with plotrix package function textbox(): # 1. 'cex' wasn't getting passed to text() so wasn't effective. # 2. Top of box was higher than specified y. # 3. Save and restore par('adj') # 4. 'justify' didn't do anything. Redefined to left/center/right justify. Text # filling could be added later when value = TRUE. # And added features: # 1. New 'margin' argument. # 2. New arguments passed to text() and rect(): adj, font, vfont, col, border, fill, # density, angle, lty, lwd. # # textbox Draw text in a box # ####################################################################################### textbox <- function(x, y, textlist, justify=c('l','c','r'), cex=1, leading=0.5, box=TRUE, adj=c(0,0), font=NULL, vfont=NULL, col=NULL, border=NULL, fill=NA, density=NULL, angle=45, lty=par("lty"), lwd=par("lwd"), margin=0) { if (length(margin) == 1) margin <- rep(margin, 4) else if (length(margin) == 2) margin <- rep(margin, 2) saveAdj <- par(adj=0) textstr <- paste(textlist, collapse=" ") words <- strsplit(textstr, " ")[[1]] line.height <- strheight("hy", cex=cex, font=font, vfont=vfont) * (1+leading) if (margin[2] > 0) x[1] <- x[1] + margin[2] if (margin[3] > 0) y <- y - margin[3] if (margin[4] > 0) x[2] <- x[2] - margin[4] if (x[1] >= x[2]) x[2] <- x[1] + diff(par("usr")[1:2])*0.1 x.len <- diff(x) y.pos <- y x.pos <- x[1] adj2 <- c(0,1) if (justify[1] == 'c') { x.pos <- x.pos + x.len/2 adj2[1] <- 0.5 } else if (justify[1] == 'r') { x.pos <- x.pos + x.len adj2[1] <- 1 } curword <- 1 while (curword <= length(words)) { curline <- "" curline <- paste(curline, words[curword]) curword <- curword + 1 while (strwidth(paste(curline, words[curword]), cex=cex, font=font, vfont=vfont) < x.len && !is.na(words[curword])) { curline <- paste(curline, words[curword]) curword <- curword + 1 } text(x.pos, y.pos, curline, adj=adj+adj2, cex=cex, col=col, font=font, vfont=vfont) y.pos <- y.pos - line.height } if (box) { xbox <- x ybox <- c(y.pos, y) ybox[1] <- ybox[1] - abs(margin[1]) xbox[1] <- xbox[1] - abs(margin[2]) ybox[2] <- ybox[2] + abs(margin[3]) xbox[2] <- xbox[2] + abs(margin[4]) rect(xbox[1], ybox[1], xbox[2], ybox[2], border=border, col=fill, density=density, angle=angle, lty=lty, lwd=lwd) y.pos <- ybox[1] } par(saveAdj) return(y.pos) }plotrix/R/taylor.diagram.R0000755000176000001440000001555212004463014015251 0ustar ripleyusers# Display a Taylor diagram # Taylor K.E. (2001) # Summarizing multiple aspects of model performance in a single diagram # Journal of Geophysical Research, 106: 7183-7192. # version 1.0 # progr. Olivier.Eterradossi, 12/2007 # 2007-01-12 - modifications and Anglicizing - Jim Lemon # version 2.0 # progr. initiale OLE, 8/01/2007 # rev. OLE 3/09/2008 : remove samples with NA's from mean, sd and cor calculations # 2008-09-04 - integration and more anglicizing - Jim Lemon # 2008-12-09 - added correlation radii, sd arcs to the pos.cor=FALSE routine # and stopped the pos.cor=FALSE routine from calculating arcs for zero radius # Jim Lemon # 2010-4-30 - added the gamma.col argument for pos.cor=TRUE plots - Jim Lemon # 2010-6-24 - added mar argument to pos.cor=TRUE plots - Jim Lemon # 2012-1-31 - added the cex.axis argument - Jim Lemon taylor.diagram<-function(ref,model,add=FALSE,col="red",pch=19,pos.cor=TRUE, xlab="",ylab="",main="Taylor Diagram",show.gamma=TRUE,ngamma=3,gamma.col=8, sd.arcs=0,ref.sd=FALSE,grad.corr.lines=c(0.2,0.4,0.6,0.8,0.9),pcex=1, cex.axis=1,normalize=FALSE,mar=c(5,4,6,6),...) { grad.corr.full<-c(0,0.2,0.4,0.6,0.8,0.9,0.95,0.99,1) R<-cor(ref,model,use="pairwise") # convert any list elements or data frames to vectors if(is.list(ref)) ref<-unlist(ref) if(is.list(model)) ref<-unlist(model) sd.r<-sd(ref) sd.f<-sd(model) if(normalize) { sd.f<-sd.f/sd.r sd.r<-1 } maxsd<-1.5*max(sd.f,sd.r) oldpar<-par("mar","xpd","xaxs","yaxs") if(!add) { # display the diagram if(pos.cor) { if(nchar(ylab) == 0) ylab="Standard deviation" par(mar=mar) plot(0,xlim=c(0,maxsd),ylim=c(0,maxsd),xaxs="i",yaxs="i",axes=FALSE, main=main,xlab=xlab,ylab=ylab,type="n",cex=cex.axis,...) if(grad.corr.lines[1]) { for(gcl in grad.corr.lines) lines(c(0,maxsd*gcl),c(0,maxsd*sqrt(1-gcl^2)),lty=3) } # add the axes segments(c(0,0),c(0,0),c(0,maxsd),c(maxsd,0)) axis.ticks<-pretty(c(0,maxsd)) axis.ticks<-axis.ticks[axis.ticks<=maxsd] axis(1,at=axis.ticks,cex.axis=cex.axis) axis(2,at=axis.ticks,cex.axis=cex.axis) if(sd.arcs[1]) { if(length(sd.arcs) == 1) sd.arcs<-axis.ticks for(sdarc in sd.arcs) { xcurve<-cos(seq(0,pi/2,by=0.03))*sdarc ycurve<-sin(seq(0,pi/2,by=0.03))*sdarc lines(xcurve,ycurve,col="blue",lty=3) } } if(show.gamma[1]) { # if the user has passed a set of gamma values, use that if(length(show.gamma) > 1) gamma<-show.gamma # otherwise make up a set else gamma<-pretty(c(0,maxsd),n=ngamma)[-1] if(gamma[length(gamma)] > maxsd) gamma<-gamma[-length(gamma)] labelpos<-seq(45,70,length.out=length(gamma)) # do the gamma curves for(gindex in 1:length(gamma)) { xcurve<-cos(seq(0,pi,by=0.03))*gamma[gindex]+sd.r # find where to clip the curves endcurve<-which(xcurve<0) endcurve<-ifelse(length(endcurve),min(endcurve)-1,105) ycurve<-sin(seq(0,pi,by=0.03))*gamma[gindex] maxcurve<-xcurve*xcurve+ycurve*ycurve startcurve<-which(maxcurve>maxsd*maxsd) startcurve<-ifelse(length(startcurve),max(startcurve)+1,0) lines(xcurve[startcurve:endcurve],ycurve[startcurve:endcurve], col=gamma.col) if(xcurve[labelpos[gindex]] > 0) boxed.labels(xcurve[labelpos[gindex]],ycurve[labelpos[gindex]], gamma[gindex],border=FALSE) } } # the outer curve for correlation xcurve<-cos(seq(0,pi/2,by=0.01))*maxsd ycurve<-sin(seq(0,pi/2,by=0.01))*maxsd lines(xcurve,ycurve) bigtickangles<-acos(seq(0.1,0.9,by=0.1)) medtickangles<-acos(seq(0.05,0.95,by=0.1)) smltickangles<-acos(seq(0.91,0.99,by=0.01)) segments(cos(bigtickangles)*maxsd,sin(bigtickangles)*maxsd, cos(bigtickangles)*0.97*maxsd,sin(bigtickangles)*0.97*maxsd) par(xpd=TRUE) if(ref.sd) { # the inner curve for reference SD xcurve<-cos(seq(0,pi/2,by=0.01))*sd.r ycurve<-sin(seq(0,pi/2,by=0.01))*sd.r lines(xcurve,ycurve) } points(sd.r,0,cex=pcex) text(cos(c(bigtickangles,acos(c(0.95,0.99))))*1.05*maxsd, sin(c(bigtickangles,acos(c(0.95,0.99))))*1.05*maxsd, c(seq(0.1,0.9,by=0.1),0.95,0.99)) text(maxsd*0.8,maxsd*0.8,"Correlation",srt=315) segments(cos(medtickangles)*maxsd,sin(medtickangles)*maxsd, cos(medtickangles)*0.98*maxsd,sin(medtickangles)*0.98*maxsd) segments(cos(smltickangles)*maxsd,sin(smltickangles)*maxsd, cos(smltickangles)*0.99*maxsd,sin(smltickangles)*0.99*maxsd) } else { x<- ref y<- model R<-cor(x,y,use="pairwise.complete.obs") E<-mean(x,na.rm=TRUE)-mean(y,na.rm=TRUE) # overall bias xprime<-x-mean(x,na.rm=TRUE) yprime<-y-mean(y,na.rm=TRUE) sumofsquares<-(xprime-yprime)^2 Eprime<-sqrt(sum(sumofsquares)/length(complete.cases(x))) # centered pattern RMS E2<-E^2+Eprime^2 if (add==FALSE) { # pourtour du diagramme (display the diagram) maxray<-1.5*max(sd.f,sd.r) plot(c(-maxray,maxray),c(0,maxray),type="n",asp=1,bty="n",xaxt="n",yaxt="n", xlab=xlab,ylab=ylab,main=main,cex=cex.axis) discrete<-seq(180,0,by=-1) listepoints<-NULL for (i in discrete){ listepoints<-cbind(listepoints,maxray*cos(i*pi/180),maxray*sin(i*pi/180)) } listepoints<-matrix(listepoints,2,length(listepoints)/2) listepoints<-t(listepoints) lines(listepoints[,1],listepoints[,2]) # axes x,y lines(c(-maxray,maxray),c(0,0)) lines(c(0,0),c(0,maxray)) # lignes radiales jusqu'� R = +/- 0.8 for (i in grad.corr.lines){ lines(c(0,maxray*i),c(0,maxray*sqrt(1-i^2)),lty=3) lines(c(0,-maxray*i),c(0,maxray*sqrt(1-i^2)),lty=3) } # texte radial for (i in grad.corr.full){ text(1.05*maxray*i,1.05*maxray*sqrt(1-i^2),i,cex=0.6) text(-1.05*maxray*i,1.05*maxray*sqrt(1-i^2),-i,cex=0.6) } # sd concentriques autour de la reference seq.sd<-seq.int(0,2*maxray,by=(maxray/10))[-1] for (i in seq.sd){ xcircle<-sd.r+(cos(discrete*pi/180)*i) ycircle<-sin(discrete*pi/180)*i for (j in 1:length(xcircle)){ if ((xcircle[j]^2+ycircle[j]^2)<(maxray^2)){ points(xcircle[j],ycircle[j], col="darkgreen",pch=".") if(j==10) text(xcircle[j],ycircle[j],signif(i,2),cex=0.5,col="darkgreen") } } } # sd concentriques autour de l'origine seq.sd<-seq.int(0,maxray,length.out=5) for (i in seq.sd){ xcircle<-(cos(discrete*pi/180)*i) ycircle<-sin(discrete*pi/180)*i if(i) lines(xcircle,ycircle,lty=3,col="blue") text(min(xcircle),-0.03*maxray,signif(i,2),cex=0.5,col="blue") text(max(xcircle),-0.03*maxray,signif(i,2),cex=0.5,col="blue") } text(0,-0.08*maxray,"Standard Deviation",cex=0.7,col="blue") text(0,-0.12*maxray,"Centered RMS Difference",cex=0.7,col="darkgreen") points(sd.r,0,pch=22,bg="darkgreen",cex=1.1) text(0,1.1*maxray,"Correlation Coefficient",cex=0.7) } S<-(2*(1+R))/(sd.f+(1/sd.f))^2 # Taylor<-S } } # display the points points(sd.f*R,sd.f*sin(acos(R)),pch=pch,col=col,cex=pcex) invisible(oldpar) } plotrix/R/tab.title.R0000755000176000001440000000240611354472242014226 0ustar ripleyuserstab.title<-function(label,text.col=par("fg"),tab.col=par("bg"), border=par("fg"),lwd=par("lwd"),cex=1.5,pad.mult=1.6,radius=0) { plotin<-par("pin") marin<-par("mai") plim<-par("usr") xmult<-(plim[2]-plim[1])/(plim[4]-plim[3])*plotin[2]/plotin[1] plim[3]<-plim[4] plim[4]<-plim[3]+((plim[2]-plim[1])/xmult)*marin[3]/plotin[2] oldcex<-par("cex") par(cex=cex) tabtop<-plim[3]+strheight(label)*pad.mult oldxlog<-par("xlog") oldylog<-par("ylog") par(xlog=FALSE,ylog=FALSE) if(radius == 0) { tabx<-c(plim[1],plim[1],plim[2],plim[2]) taby<-c(plim[3],tabtop,tabtop,plim[3]) } else { xradius<-radius*(tabtop-plim[3])*xmult xcurve1<-xradius*cos(seq(0,pi/2,length.out=20)) xcurve2<-xradius*cos(seq(pi/2,pi,length.out=20)) tabx<-c(plim[2], (plim[2]-xradius)+xcurve1, (plim[1]+xradius)+xcurve2, plim[1]) yradius<-radius*(tabtop-plim[3]) ycurve1<-yradius*sin(seq(0,pi/2,length.out=20)) ycurve2<-yradius*sin(seq(pi/2,pi,length.out=20)) taby<-c(plim[3], tabtop-yradius+ycurve1, tabtop-yradius+ycurve2, plim[3]) } par(xpd=TRUE) polygon(tabx,taby,border=border,col=tab.col,lwd=lwd) text((plim[1]+plim[2])/2,(plim[3]+tabtop)/2,label, col=text.col) par(xpd=FALSE,xlog=oldxlog,ylog=oldylog,cex=oldcex) } plotrix/R/symbolbox.R0000755000176000001440000000175111056465626014367 0ustar ripleyuserssymbolbox<-function(x1,y1,x2,y2,tot,relw=0.5,fg=par("fg"),bg=par("bg"), box=TRUE,debug=TRUE,...) { if(debug) cat("symbolbox:",x1,y1,x2,y2,tot,"\n") x <- c(x1,x2) y <- c(y1,y2) if (x2 < x1) x<-rev(x) if (y2 < y1) y<-rev(y) pin<-par("pin") usr<-par("usr") usr.pin<-diff(par("usr"))[c(1,3)]/par("pin") dx<-diff(x)/usr.pin[1] dy<-diff(y)/usr.pin[2] area<-dx*dy m<-dx*sqrt(tot/area) n<-dy*sqrt(tot/area) rm<-max(round(m),1) rn<-max(round(n),1) while(rm*rn < tot) { if((dx*sqrt(tot/area)-m) > (dy*sqrt(tot/area)-n)) { rm <- rm + 1 } else { rn <- rn + 1 } } m<-rm n<-rn if(debug) cat("symbolbox:",dx,dy,m,n,rm,rn,tot,"\n") r<-dx/m*relw/2 dx<-dx/m*usr.pin[1] dy<-dy/n*usr.pin[2] mat<-matrix(1:(m*n),nrow=m,ncol=n) xpos<-x[1]+(row(mat)[mat <= tot] - 0.5) * dx ypos<-y[1]+(col(mat)[mat <= tot] - 0.5) * dy symbols(xpos,ypos,rep(1,tot),bg=bg,fg=fg,add=TRUE,inches=r) if(box) polygon(x[c(1,1,2,2,1)],y[c(1,2,2,1,1)],border=fg,...) } plotrix/R/symbolbarplot.R0000755000176000001440000000623711573136002015231 0ustar ripleyuserssymbolbarplot<-function(height,width=1,space=NULL,names.arg=NULL, legend.text=NULL,beside=FALSE,horiz=FALSE,col=heat.colors(NR), border=par("fg"),main=NULL,sub=NULL,xlab=NULL,ylab=NULL, xlim=NULL,ylim=NULL,axes=TRUE,axisnames=TRUE,inside=TRUE, plot=TRUE,rel.width=0.8,symbol="circles",symbbox=TRUE,debug=FALSE,...) { if(!missing(inside)) .NotYetUsed("inside", error = FALSE) if(!missing(border)) .NotYetUsed("border", error = FALSE) if(missing(space)) space<-if(is.matrix(height) && beside) c(0, 1) else 0.2 space<-space*mean(width) if(plot && axisnames && missing(names.arg)) names.arg<-if (is.matrix(height)) colnames(height) else names(height) if(is.vector(height)) { height <- cbind(height) beside <- TRUE } else { if(is.array(height) && (length(dim(height)) == 1)) { height <- rbind(height) beside <- TRUE } else if(!is.matrix(height)) stop("`height' must be a vector or a matrix") } NR <- nrow(height) NC <- ncol(height) if(beside) { if(length(space) == 2) space <- rep(c(space[2],rep(space[1],NR - 1)),NC) width <- rep(width,length = NR * NC) } else { width <- rep(width,length = NC) height <- rbind(0,apply(height,2,cumsum)) } delta <- width/2 w.r <- cumsum(space + width) w.m <- w.r - delta w.l <- w.m - delta if(horiz) { if(missing(xlim)) xlim <- range(-0.01 * height, height) if(missing(ylim)) ylim <- c(min(w.l), max(w.r)) } else { if(missing(xlim)) xlim <- c(min(w.l), max(w.r)) if(missing(ylim)) ylim <- range(-0.01 * height, height) } if(beside) w.m <- matrix(w.m, ncol = NC) if(plot) { opar<- if (horiz) par(xaxs = "i", xpd = TRUE) else par(yaxs = "i", xpd = TRUE) on.exit(par(opar)) plot.new() plot.window(xlim, ylim, log = "", ...) xyrect<-function(x1,y1,x2,y2,horizontal = TRUE,n,col,...) { if(horizontal) multsymbolbox(x1, y1, x2, y2, tot = x2 - x1, bg = col, fg = col, relw = rel.width, box = symbbox, debug = debug, ...) else multsymbolbox(y1, x1, y2, x2, tot = x2 - x1, bg = col, fg = col, relw = rel.width, box = symbbox, debug = debug, ...) } if(beside) xyrect(0,w.l,c(height),w.r,horizontal=horiz,col=col,n=c(height)) else { for (i in 1:NC) { xyrect(height[1:NR, i], w.l[i], height[-1, i], w.r[i], horizontal = horiz, col = col, n = height[1:NR,i]) } } if(axisnames && !is.null(names.arg)) { at.l<- if(length(names.arg) != length(w.m)) { if(length(names.arg) == NC) apply(w.m, 2, mean) else stop("incorrect number of names") } else w.m axis(if(horiz) 2 else 1,at=at.l,labels=names.arg,lty = 0) } if(!is.null(legend.text)) { legend.col <- rep(col, length = length(legend.text)) if ((horiz & beside) || (!horiz & !beside)) { legend.text <- rev(legend.text) legend.col <- rev(legend.col) } xy<-par("usr") legend(xy[2] - xinch(0.1), xy[4] - yinch(0.1), legend = legend.text, fill = legend.col, xjust = 1, yjust = 1) } title(main = main,sub = sub,xlab = xlab,ylab = ylab,...) if(axes) axis(if(horiz) 1 else 2) invisible(w.m) } else w.m } plotrix/R/std.error.R0000755000176000001440000000057211061207644014261 0ustar ripleyusersstd.error<-function(x,na.rm) { vn<-function(x) return(sum(!is.na(x))) dimx<-dim(x) if(is.null(dimx)) { stderr<-sd(x,na.rm=TRUE) vnx<-vn(x) } else { if(is.data.frame(x)) { vnx<-unlist(sapply(x,vn)) stderr<-unlist(sapply(x,sd,na.rm=TRUE)) } else { vnx<-unlist(apply(x,2,vn)) stderr<-unlist(apply(x,2,sd,na.rm=TRUE)) } } return(stderr/sqrt(vnx)) } plotrix/R/staxlab.R0000755000176000001440000000246011712460136013773 0ustar ripleyusers# staxlab produces staggered axis tick labels # note that barplot() tends to mess things up by plotting an X axis # even when axes=FALSE staxlab<-function(side=1,at,labels,nlines=2,top.line=0.5, line.spacing=0.8,srt=NA,ticklen=0.03,adj=1,...) { if(missing(labels)) labels<-at nlabels<-length(labels) if(missing(at)) at<-1:nlabels if(is.na(srt)) { linepos<-rep(top.line,nlines) for(i in 2:nlines) linepos[i]<-linepos[i-1]+line.spacing linepos<-rep(linepos,ceiling(nlabels/nlines))[1:nlabels] axis(side=side,at=at,labels=rep("",nlabels)) mtext(text=labels,side=side,line=linepos,at=at,...) } else { xylim<-par("usr") if(side == 1) { xpos<-at if(par("ylog")) ypos<-10^(xylim[3]-ticklen*(xylim[4]-xylim[3])) else ypos<-xylim[3]-ticklen*(xylim[4]-xylim[3]) } if(side == 3) { xpos<-at if(par("ylog")) ypos<-10^(xylim[4]+ticklen*(xylim[4]-xylim[3])) else ypos<-xylim[4]+ticklen*(xylim[4]-xylim[3]) } if(side == 2) { ypos<-at if(par("xlog")) xpos<-10^(xylim[1]-ticklen*(xylim[2]-xylim[1])) else xpos<-xylim[1]-ticklen*(xylim[2]-xylim[1]) } if(side == 4) { ypos<-at if(par("xlog")) xpos<-10^(xylim[2]+ticklen*(xylim[2]-xylim[1])) else xpos<-xylim[2]+ticklen*(xylim[2]-xylim[1]) } par(xpd=TRUE) text(xpos,ypos,labels,srt=srt,adj=adj,...) par(xpd=FALSE) } } plotrix/R/staircase.plot.R0000755000176000001440000001032212077707345015277 0ustar ripleyusersstaircase.plot<-function(heights,totals=NA,labels=NULL,halfwidth=0.3,main="", mar=NA,total.col="blue",inc.col=NA,bg.col=NA,direction="e",las=1, display.height=TRUE,stagger=FALSE,cex=par("cex"),prefix="",suffix="",...) { staircasePlot(heights=heights,totals=totals,labels=labels,halfwidth=halfwidth, main=main,mar=mar,stair.info=list(total.col=total.col,inc.col=inc.col, border=par("fg")),bg.col=bg.col,direction=direction,las=las, display.height=display.height,stagger=stagger,cex=cex,prefix=prefix, suffix=suffix,...) } staircasePlot<-function(heights,totals=NA,labels=NULL,halfwidth=0.3,main="", mar=NA,stair.info=list(total.col="blue",inc.col=NA,border=par("fg")), bg.col=NA,direction="e",las=1,display.height=TRUE,stagger=FALSE,cex=par("cex"), prefix="",suffix="",...) { if(is.matrix(heights) | is.data.frame(heights)) { dimheights<-dim(heights) if(dimheights[2] > 1) totals<-heights[,2] heights<-as.vector(heights) } if(!is.numeric(heights)) stop("heights must be a numeric vector or matrix/data frame with numeric first column") nbars<-length(heights) if(length(prefix) < nbars) prefix<-rep(prefix,length.out=nbars) if(length(suffix) < nbars) suffix<-rep(suffix,length.out=nbars) # if no marker for increments (FALSE | 0) and totals (TRUE | non-zero) # consider the first and last values to be totals and all others increments if(is.na(totals[1])) totals<-c(TRUE,rep(FALSE,nbars-2),TRUE) # coerce totals to a logical vector if it isn't if(!is.logical(totals)) totals<-totals != 0 oldmar<-par("mar") if(!is.na(bg.col)) { oldbg<-par("bg") par(bg=bg.col) } maxht<-max(heights) # if there is a negative total height, make that the minimum, otherwise zero minht<-min(c(min(heights[totals]),0)) currht<-heights[1] for(i in 2:nbars) { if(!totals[i]) { currht<-currht+heights[i] if(currht > maxht) maxht<-currht } } if(direction == "e" || direction == "w") { if(is.na(mar[1])) mar<-c(10,2,3,2) par(mar=mar,xaxs="i") plot(0,xlim=c(0.5,nbars+0.5),ylim=c(minht,maxht),type="n",axes=FALSE, xlab="",ylab="",...) } else { if(is.na(mar[1])) mar<-c(2,10,3,2) par(mar=mar,yaxs="i") plot(0,xlim=c(minht,maxht),ylim=c(0.5,nbars+0.5),type="n",axes=FALSE, xlab="",ylab="",...) } par(xpd=TRUE) bar.col<-rep(NA,nbars) if(length(stair.info$inc.col) < sum(!totals)) stair.info$inc.col=rep(stair.info$inc.col,length.out=sum(!totals)) bar.col[!totals]<-stair.info$inc.col bar.col[totals]<-stair.info$total.col label_offset<-ifelse(direction == "e" || direction == "w", strheight("M"),strwidth("M")) if(direction == "s" || direction == "w") { start<-nbars finish<-1 dir<- -1 } else { start<-1 finish<-nbars dir<-1 } barend<-0 barpos<-start:finish for(bar in 1:nbars) { barstart<-ifelse(totals[bar],0,barend) barend<-barstart+heights[bar] if(direction == "e" || direction == "w") { rect(barpos[bar]-halfwidth,barstart,barpos[bar]+halfwidth,barend, col=bar.col[bar],border=stair.info$border) if(display.height) text(barpos[bar],ifelse(heights[bar]<0,barstart,barend)+label_offset, paste(prefix[bar],heights[bar],suffix[bar],sep=""),cex=cex) if(direction == "e" && bar != nbars) segments(barpos[bar]+halfwidth*dir,barend,barpos[bar]+dir-halfwidth*dir, barend,lty=3) if(direction == "w" && bar != nbars) segments(barpos[bar]-halfwidth*dir,barend,barpos[bar]+dir+halfwidth*dir, barend,lty=3) if(!is.null(labels)) { labelline<-0.2 if(stagger) labelline<-c(labelline,1.2) mtext(labels,side=1,line=labelline,at=start:finish,adj=0.5,padj=1, las=las,cex=cex) } } else { rect(barstart,barpos[bar]-halfwidth,barend,barpos[bar]+halfwidth, col=bar.col[bar]) if(display.height) text(ifelse(heights[bar]<0,barstart,barend)+label_offset, barpos[bar],paste(prefix[bar],heights[bar],suffix[bar],sep=""),adj=0,cex=cex) if(bar != nbars) segments(barend,barpos[bar]+halfwidth*dir,barend, barpos[bar]+dir-halfwidth*dir,lty=3) if(!is.null(labels)) { labelline<-0.5 if(stagger) labelline<-c(labelline,1.5) mtext(labels,side=2,line=labelline,at=start:finish,adj=1,las=las,cex=cex) } } } if(nchar(main)) mtext(main,line=mar[3]/2,at=getFigCtr()[1],cex=1.5) par(xpd=FALSE,mar=oldmar) if(!is.na(bg.col)) par(bg=oldbg) } plotrix/R/stackpoly.R0000755000176000001440000000334611426507046014356 0ustar ripleyusersstackpoly<-function(x,y=NULL,main="",xlab="",ylab="",xat=NA,xaxlab=NA, xlim=NA,ylim=NA,lty=1,lwd=1,border=NA,col=NULL,staxx=FALSE,stack=FALSE, axis2=TRUE,axis4=TRUE,padj=0,...) { ydim<-dim(y) if(is.null(y[1])) { y<-x ydim<-dim(y) if(is.null(ydim)) x<-1:length(y) else x<-matrix(rep(1:ydim[1],ydim[2]),ncol=ydim[2]) } if(stack) y<-t(unlist(apply(as.matrix(y),1,cumsum))) if(is.na(xlim[1])) xlim<-range(x) if(is.na(ylim[1])) ylim<-range(y) plot(0,main=main,xlab=xlab,ylab=ylab,xlim=xlim,ylim=ylim,type="n", xaxs="i",yaxs="i",axes=FALSE,...) if(is.matrix(y) || is.list(y)) { plotlim<-par("usr") if(is.na(xat[1])) xat<-x[,1] if(is.na(xaxlab[1])) xaxlab<-xat if(staxx) staxlab(at=xat,labels=xaxlab) else axis(1,at=xat,labels=xaxlab,padj=padj) if(axis2) axis(2) if(axis4) axis(4) if(is.null(col[1])) col=rainbow(ydim[2]) else if(length(col) 0) { while(end < gxlen && goodx[end+1] - goodx[end] < mindist) end<-end+1 while(start > 1 && goodx[start] - goodx[start-1] < mindist) start<-start-1 if(start < end) { nsqueezed<-1+end-start newx<-sum(goodx[start:end])/nsqueezed - mindist*(nsqueezed%/%2 - (nsqueezed/2 == nsqueezed%/%2) * 0.5) for(stretch in start:end) { goodx[stretch]<-newx newx<-newx+mindist } } start<-end<-start-1 } start<-end<-length(goodx)%/%2+1 while(start < gxlen) { while(start > 1 && goodx[start] - goodx[start-1] < mindist) start<-start-1 while(end < gxlen && goodx[end+1] - goodx[end] < mindist) end<-end+1 if(start < end) { nsqueezed<-1+end-start newx<-sum(goodx[start:end])/nsqueezed - mindist*(nsqueezed%/%2 - (nsqueezed/2 == nsqueezed%/%2) * 0.5) for(stretch in start:end) { goodx[stretch]<-newx newx<-newx+mindist } } start<-end<-end+1 } # force any remaining short intervals apart if(any(diff(goodx) < mindist)) { start<-gxlen%/%2 while(start > 1) { if(goodx[start] - goodx[start-1] < mindist) goodx[start-1]<-goodx[start]-mindist start<-start-1 } end<-gxlen%/%2 while(end < gxlen) { if(goodx[end+1] - goodx[end] < mindist) goodx[end+1]<-goodx[end]+mindist end<-end+1 } } x[xorder][!is.na(x[xorder])]<-goodx return(x) } plotrix/R/spread.labels.R0000755000176000001440000000420711763075745015073 0ustar ripleyusersspread.labels<-function (x,y,labels=NULL,ony=NA,offsets=NA,between=FALSE, linecol=par("fg"),srt=0,...) { if(missing(x)) stop("Usage: spread.labels(x,y,labels,...)") nx<-length(x) ny<-length(y) if(is.na(ony)) { xylim<-par("usr") ony<-diff(range(x))/(xylim[2]-xylim[1]) 0) || all(offsets < 0)) seggaps<-rep(seggap*(all(offsets)<0)*-1,length.out=nx) else seggaps<-rep(c(seggap,-seggap),length.out=nx) segments(newx,y+offsets-seggaps,x,y) } } } plotrix/R/soil.texture.uk.R0000755000176000001440000000432011446374464015431 0ustar ripleyusers# UK soil texture plot soil.texture.uk <- function (soiltexture = NULL, main = "", at = seq(0.1, 0.9, by = 0.1), axis.labels = c("percent sand", "percent silt", "percent clay"), tick.labels = list(l = seq(10, 90, by = 10), r = seq(10, 90, by = 10), b = seq(10, 90, by = 10)), show.names = TRUE, show.lines = TRUE, col.names = "gray", bg.names = par("bg"), show.grid = FALSE, col.axis = "black", col.lines = "gray", col.grid = "gray", lty.grid = 3, show.legend = FALSE, label.points = FALSE, point.labels = NULL, col.symbols = "black", pch = par("pch"), h1 = NA, h3 = NA, t1 = NA, t3 = NA, lwduk = 2, xpos = NA, ypos = NA, snames = NA, cexuk = 1.1, ...) { if(is.na(h1[1])) h1<-c(82, 85, 70, 50, 45, 20) / 100 if(is.na(h3[1])) h3<-c(18, 15, 30, 30, 35, 0) / 100 if(is.na(t1[1])) t1<-c(0, 70, 50, 45, 0, 20) / 100 if(is.na(t3[1])) t3<-c(18, 0, 30, 35, 35, 35) / 100 # Name positions (x and y, x starting form left point) if(is.na(xpos[1])) xpos<-c(0.5,0.77,0.45,0.1,0.45,0.85) if(is.na(ypos[1])) ypos<-c(0.65,0.265,0.265,0.07,0.1,0.1) if(is.na(snames[1])) snames <- c("Clays","Medium silts","Medium loams", "Sands","Light loams","Light silts") par(xpd = TRUE) plot(0.5, type = "n", axes = FALSE, xlim = c(0,1),ylim = c(0,1), main = NA, xlab = NA, ylab = NA) triax.plot(x=NULL,main = main, at = at, axis.labels = axis.labels, tick.labels = tick.labels, col.axis = col.axis, show.grid = show.grid, col.grid = col.grid, lty.grid = lty.grid) arrows(0.12, 0.41, 0.22, 0.57, length = 0.15) arrows(0.78, 0.57, 0.88, 0.41, length = 0.15) arrows(0.6, -0.1, 0.38, -0.1, length = 0.15) if(show.lines) { triax.segments <- function(h1, h3, t1, t3, col, lwd) { segments(1 - h1 - h3/2, h3 * sin(pi/3), 1 - t1 - t3/2, t3 * sin(pi/3), col = col, lwd = lwd) } triax.segments(h1 , h3, t1, t3, col.lines, lwduk) } if (show.names) { boxed.labels(xpos, ypos* sin(pi/3), snames, border = FALSE, xpad = 0.5, cex = cexuk) } par(xpd = FALSE) if (is.null(soiltexture)) return(NULL) soilpoints <- triax.points(soiltexture, show.legend = show.legend, label.points = label.points, point.labels = point.labels, col.symbols = col.symbols, pch = pch, ...) invisible(soilpoints) } plotrix/R/soil.texture.R0000755000176000001440000000435011446374032015005 0ustar ripleyusersget.soil.texture<-function(use.percentages=FALSE,cnames=c("sand","silt","clay")) { return(get.triprop(use.percentages=use.percentages, cnames=cnames)) } soil.texture<-function(soiltexture=NULL,main="",at=seq(0.1,0.9,by=0.1), axis.labels=c("percent sand","percent silt","percent clay"), tick.labels=list(l=seq(10,90,by=10),r=seq(10,90,by=10),b=seq(10,90,by=10)), show.names=TRUE,show.lines=TRUE,col.names="gray",bg.names=par("bg"), show.grid=FALSE,col.axis="black",col.lines="gray",col.grid="gray", lty.grid=3,show.legend=FALSE,label.points=FALSE,point.labels=NULL, col.symbols="black",pch=par("pch"), ...) { par(xpd=TRUE) plot(0.5,type="n",axes=FALSE,xlim=c(0,1),ylim=c(0,1),main=NA,xlab=NA, ylab=NA) triax.plot(x=NULL,main=main,at=at,axis.labels=axis.labels,tick.labels=tick.labels, col.axis=col.axis,show.grid=show.grid,col.grid=col.grid,lty.grid=lty.grid) arrows(0.12,0.41,0.22,0.57,length=0.15) arrows(0.78,0.57,0.88,0.41,length=0.15) arrows(0.6,-0.1,0.38,-0.1,length=0.15) if(show.lines) { triax.segments<-function(h1,h3,t1,t3,col) { segments(1-h1-h3/2,h3*sin(pi/3),1-t1-t3/2,t3*sin(pi/3),col=col) } # from bottom-left to up h1 <- c(85, 70, 80, 52, 52, 50, 20, 8, 52, 45, 45, 65, 45, 20, 20)/100 h3 <- c( 0, 0, 20, 20, 7, 0, 0, 12, 20, 27, 27, 35, 40, 27, 40)/100 t1 <- c(90, 85, 52, 52, 43, 23, 8, 0, 45, 0, 45, 45, 0, 20, 0)/100 t3 <- c(10, 15, 20, 7, 7, 27, 12, 12, 27, 27, 55, 35, 40, 40, 60)/100 triax.segments(h1, h3, t1, t3, col.lines) } if(show.names) { xpos <- c(0.5, 0.7, 0.7, 0.73, 0.73, 0.5, 0.275, 0.275, 0.27, 0.27, 0.25, 0.135, 0.18, 0.055, 0.49, 0.72, 0.9) ypos <- c(0.66, 0.49, 0.44, 0.36, 0.32, 0.35, 0.43, 0.39, 0.3, 0.26, 0.13, 0.072, 0.032, 0.024, 0.18, 0.15, 0.06)*sin(pi/3) snames <- c("clay", "silty", "clay", "silty clay", "loam", "clay loam", "sandy", "clay", "sandy clay", "loam", "sandy loam", "loamy", "sand", "sand", "loam", "silt loam", "silt") boxed.labels(xpos, ypos, snames, border=FALSE, xpad=0.5) } par(xpd=FALSE) # now call triax.points if(is.null(soiltexture)) return(NULL) soilpoints <- triax.points(soiltexture, show.legend=show.legend, label.points=label.points, point.labels=point.labels, col.symbols=col.symbols, pch=pch, ...) invisible(soilpoints) } plotrix/R/smoothColors.R0000755000176000001440000000273611056465626015050 0ustar ripleyuserssmoothColors<-function(...,alpha=NA){ args <- list(...) r <- g <- b <- NULL while(length(args) > 0) { if(!is.character(args[[1]])) stop("Usage: smoothColors(\"color name\",[n|\"color name\"],...,\"color name\")") arglen<-length(args) if(arglen > 1){ if(is.numeric(args[[2]])){ lastarg<-2 # args[[lastarg]] should be a color name while(is.numeric(args[[lastarg]])) { lastarg<-lastarg+1 # make sure that there are enough arguments left if(lastarg > arglen) stop("bad argument list") } ## do interpolate: from <- col2rgb(args[[1]]) too <- col2rgb(args[[lastarg]]) ## generate args[[2]] colors between specified colors: n <- args[[2]]+2 # add 2 for start and finish ## chop off last one since it will be added on the next iteration: r <- c(r,seq(from[1,],too[1,],length=n)) i <- length(r) r <- r[-i] g <- c(g,seq(from[2,],too[2,],length=n)) g <- g[-i] b <- c(b,seq(from[3,],too[3,],length=n)) b <- b[-i] ## cut color and n from list and back we go args <- args[-(1:(lastarg-1))] } else { ## insert color, chop off 1 cc <- col2rgb(args[[1]]) r <- c(r,cc[1,]) g <- c(g,cc[2,]) b <- c(b,cc[3,]) args <- args[-1] } } else { ## insert color, chop off 1 cc <- col2rgb(args[[1]]) r <- c(r,cc[1,]) g <- c(g,cc[2,]) b <- c(b,cc[3,]) args <- args[-1] } } if(is.na(alpha)) rgb(r,g,b,maxColorValue=255) else rgb(r,g,b,alpha=alpha,maxColorValue=255) } plotrix/R/sizetree.R0000755000176000001440000000453411751710221014167 0ustar ripleyuserssizetree<-function(x,left=0,top,right=1,lastcenter=NA,showval=TRUE, showcount=TRUE,firstcall=TRUE,col=NULL,border=NA,toplab=NULL,base.cex=1,...) { dimx<-dim(x) if(firstcall) { x<-x[do.call(order,x),] oldmar<-par("mar") par(mar=c(1,2,2,1)) top<-sum(!is.na(x[,1])) if(top 0) { rect(left+squeeze,top-xfreq[bar],right-squeeze,top, col=barcol[bar],border=border) labelheight<-strheight(labels[bar]) cex<-ifelse((1.5*labelheight) > xfreq[bar], base.cex*0.75*xfreq[bar]/labelheight,base.cex) if(showval) { textcol<-ifelse(colSums(col2rgb(unlist(barcol[bar])) * c(1.4,1.4,0.5)) < 350,"white","black") bartext<-ifelse(showcount,paste(labels[bar], " (",xfreq[bar],")",sep=""),labels[bar]) text((left+right)/2,top-xfreq[bar]/2, bartext,cex=cex,col=textcol) } if(!is.na(lastcenter)) segments(left+squeeze,top-xfreq[bar]/2,left-squeeze, lastcenter) xvalue<-ifelse(is.numeric(x[, 1]),as.numeric(labels[bar]),labels[bar]) if(dimx[2] > 1) { newcol<-col newcol[[1]]<-NULL nextx<-subset(x,x[,1]==xvalue,2:dimx[2]) sizetree(nextx,right,top,right+1,lastcenter=top-xfreq[bar]/2, showval=showval,firstcall=FALSE,col=newcol,border=border,base.cex=base.cex) } } } } top<-top-xfreq[bar] } } if(firstcall) { if(!is.null(toplab)) { par(xpd=TRUE) top<-sum(!is.na(x[,1])) text(0.5:(dimx[2]+0.5),1.01*top,toplab,adj=c(0.5,0)) par(xpd=FALSE) } par(mar=oldmar) } } plotrix/R/sizeplot.R0000755000176000001440000000122011056465626014211 0ustar ripleyuserssizeplot<-function(x,y,scale=1,pow=0.5,powscale=TRUE,size=c(1,4),add=FALSE,...) { pair <- function(x, y) paste(x, y, sep = "/") unpair <- function(x) t(sapply(strsplit(x, "/"), as.numeric)) f<-factor(pair(x, y)) n<-table(f) if(min(n) == max(n)) { warning("all points repeated equally (why use sizeplot?)") if(powscale) psize <- rep(length(f), scale) else psize <- rep(length(f), size[1]) } else { if(powscale) psize<-scale*n^pow else psize<-size[1]+(size[2]-size[1])*((n-min(n))/(max(n)-min(n))) } newpts<-unpair(levels(f)) if(!add) plot(newpts[,1],newpts[,2],cex=psize,type="p",...) else points(newpts[,1],newpts[,2],cex=psize,...) } plotrix/R/size_n_color.R0000644000176000001440000000363311732571666015037 0ustar ripleyuserssize_n_color<-function(x=NULL,y,size,sizefun="sqrt",col,main="", xlim=NA,xlab="",xat=NULL,xaxlab=NULL,xcex=1,xlas=0,xgrid=FALSE, ylim=NA,ylab="",yat=NULL,yaxlab=NULL,ycex=1,ylas=1,ygrid=TRUE, mar=c(5,4,4,2),boxit=TRUE,add=FALSE,...) { if(!is.na(sizefun)) size<-do.call(sizefun,list(size)) if(is.matrix(size)) { dimsize<-dim(size) if(is.null(x)) { x<-matrix(rep((1:dimsize[2])*max(size*2),each=dimsize[1]),ncol=dimsize[2]) y<-matrix(rep((dimsize[1]:1)*max(size*2),dimsize[2]),ncol=dimsize[2]) if(is.null(xat)) xat<-x[1,] if(is.null(yat)) yat<-y[,1] } else { if(is.null(xat)) xat<-1:dimsize[2] if(is.null(yat)) yat<-1:dimsize[1] } } else { dimsize=c(length(size),1) if(is.null(x)) x<-1:length(size) } cat("length(yat)",length(yat),"\n") xylim<-par("usr") aspect_ratio<-(xylim[2]-xylim[1])/(xylim[4]-xylim[3]) maxsize<-max(size) if(is.na(xlim[1])) xlim<-c(min(x)-maxsize*aspect_ratio,max(x)+maxsize*aspect_ratio) if(is.na(ylim[1])) ylim<-c(min(y)-maxsize/aspect_ratio,max(y)+maxsize/aspect_ratio) if(!add) { oldmar<-par(mar=mar) plot(x,y,main=main,xlab=xlab,ylab=ylab,xlim=xlim,ylim=ylim, axes=FALSE,type="n",...) if(xgrid) segments(xat,xylim[3],xat,xylim[4],col="lightgray",lty=2) if(ygrid) segments(xylim[1],yat,xylim[2],yat,col="lightgray",lty=2) axis(1,at=xat,labels=xaxlab,las=xlas,cex.axis=xcex) axis(2,at=yat,labels=yaxlab,las=ylas,cex.axis=ycex) if(boxit) box() } if(is.matrix(size)) { if(is.null(dim(col))) col=matrix(col,nrow=dimsize[1],ncol=dimsize[2]) for(row in 1:dimsize[1]) { for(column in 1:dimsize[2]) draw.circle(x[row,column],y[row,column],size[row,column], border=NA,col=col[row,column]) } } else { if(length(col) < length(size)) col=rep(col,size) for(index in 1:length(size)) draw.circle(x[index],y[index],size[index],border=NA,col=col[index]) } if(!add) par(mar=oldmar) } plotrix/R/ruginv.R0000644000176000001440000000245511641052537013653 0ustar ripleyusersruginv<-function(x,ticksize=0.03,side=1,lwd=0.5,col=par("fg"), col.ticks="white",quiet=getOption("warn")<0,...) { x<-as.vector(x) ok=is.finite(x) x<-x[ok] if(!quiet) { u<-par("usr") if(side%%2 == 1) { if(par("xlog")) u<-10^u[1:2] else u<-u[1:2] } else { if(par("ylog")) u<-10^u[3:4] else u<-u[3:4] } if(any(x < u[1] | x > u[2])) warning("Some values will be clipped") } u<-par("usr") par("pin") if(ticksize < 0.5) tic<-min(diff(u[3:4]),diff(u[1:2]))*ticksize else tic<-ifelse(side%%2 == 1,diff(u[3:4]),diff(u[1:2]))*ticksize if(ticksize < 0) opar<-par(xpd=TRUE) switch(as.character(side), "1"=polygon(u[c(1,2,2,1,1)],u[3]+c(0,0,tic,tic,0),col=col,border=NA,...), "2"=polygon(u[1]+c(0,0,tic,tic,0),u[c(3,4,4,3,3)],col=col,border=NA,...), "3"=polygon(u[c(1,2,2,1,1)],u[4]+c(0,0,-tic,-tic,0),col=col,border=NA,...), "4"=polygon(u[2]+c(0,0,-tic,-tic,0),u[c(3,4,4,3,3)],col=col,border=NA,...)) switch(as.character(side), "1"=sapply(x,function(z) lines(c(z,z),u[3]+c(0,tic),col=col.ticks,lwd=lwd)), "2"=sapply(x,function(z) lines(u[1]+c(0,tic),c(z,z),col=col.ticks,lwd=lwd)), "3"=sapply(x,function(z) lines(c(z,z),u[4]+c(0,-tic),col=col.ticks,lwd=lwd)), "4"=sapply(x,function(z) lines(u[2]+c(0,-tic),c(z,z),col=col.ticks,lwd=lwd))) if(ticksize < 0) par(opar) invisible(x) } plotrix/R/rm.plot2.R0000744000176000001440000000106711747474220014021 0ustar ripleyusers raw.means.plot2 <- function(data, col.id, col.offset, col.x, col.value, fun.aggregate = "mean", ... ) { if(!is.data.frame(data)) stop("data must be a data.frame") columns <- c(col.id, col.offset, col.x, col.value) if (any(!(columns %in% colnames(data)))) stop("column not matching the data") formula.agg <- as.formula(paste(col.value, "~", col.id, "+", col.offset, "+", col.x)) d.new <- aggregate(formula.agg, data = data, FUN = fun.aggregate) raw.means.plot(d.new, col.offset = col.offset, col.x = col.x, col.value = col.value, ...) } plotrix/R/revaxis.R0000755000176000001440000000216611056465626014033 0ustar ripleyusers# Function revaxis --- rev for ``reverse'' (to reverse the direction of # axes). # # Written by T. Rolf Turner, University of New Brunswick (now # with the Starpath Project, Universtiy of Auckland). # # Some bugs fixed 7/2/02, with the assistance of Herberto Ghezzo # of McGill University. # revaxis<-function(x,y,xrev=FALSE,yrev=TRUE,xside=if(yrev) 3 else 1, yside=if(xrev) 4 else 2,xlab=NULL,ylab=NULL,bty=NULL,...) { xname <- if(is.null(xlab)) deparse(substitute(x)) else xlab yname <- if(is.null(ylab)) deparse(substitute(y)) else ylab xlab <- if(yrev) "" else xname ylab <- if(xrev) "" else yname y1 <- if(yrev) -y else y x1 <- if(xrev) -x else x old.mar <- par()$mar on.exit(par(mar = old.mar)) par(mar = old.mar[c(xside, yside, 4 - xside, 6 - yside)]) plot(x1, y1, axes = FALSE, xlab = xlab, ylab = ylab, ...) if(xrev) { axis(xside, at = pretty(-x), labels = rev(pretty(x))) mtext(side = yside, line = 2, text = yname) } else axis(xside) if(yrev) { axis(yside,at=pretty(-y),labels=rev(pretty(y)),srt=90) mtext(side=xside,line=3,text=xname) } else axis(yside) if(!is.null(bty)) box(bty = bty) invisible() } plotrix/R/rescale.R0000755000176000001440000000131011056465626013756 0ustar ripleyusers# linearly transforms a vector or matrix of numbers to a new range rescale<-function(x,newrange) { if(missing(x) | missing(newrange)) { usage.string<-paste("Usage: rescale(x,newrange)\n", "\twhere x is a numeric object and newrange is the new min and max\n", sep="",collapse="") stop(usage.string) } if(is.numeric(x) && is.numeric(newrange)) { xna<-is.na(x) if(all(xna)) return(x) if(any(xna)) xrange<-range(x[!xna]) else xrange<-range(x) # if x is constant, just return it if(xrange[1] == xrange[2]) return(x) mfac<-(newrange[2]-newrange[1])/(xrange[2]-xrange[1]) return(newrange[1]+(x-xrange[1])*mfac) } else { warning("Only numeric objects can be rescaled") return(x) } } plotrix/R/rectFill.R0000755000176000001440000000177711732545422014117 0ustar ripleyusersrectFill<-function(x1,y1,x2,y2,fg=par("fg"),bg=par("bg"),xinc=NA,yinc=NA, pch=1,pch.cex=1,pch.col=par("fg"),...) { if(is.na(xinc[1])) xinc<-strwidth(pch,cex=pch.cex) if(is.na(yinc[1])) yinc<-strheight(pch,cex=pch.cex) nrect<-length(x1) if(length(fg) < nrect) fg<-rep(fg,nrect) if(length(bg) < nrect) bg<-rep(bg,nrect) if(length(xinc) < nrect) xinc<-rep(xinc,nrect) if(length(yinc) < nrect) yinc<-rep(yinc,nrect) if(length(pch) < nrect) pch<-rep(pch,nrect) if(length(pch.cex) < nrect) pch.cex<-rep(pch.cex,nrect) if(length(pch.col) < nrect) pch.col<-rep(pch.col,nrect) for(frect in 1:nrect) { rect(x1[frect],y1[frect],x2[frect],y2[frect],col=bg[frect],border=fg[frect]) xpos<-seq(x1[frect]+xinc[frect]/2,x2[frect]-xinc[frect]/2,by=xinc[frect]) lenxpos<-length(xpos) ypos<-seq(y1[frect]+yinc[frect]/2,y2[frect]-yinc[frect]/2,by=yinc[frect]) lenypos<-length(ypos) xpos<-rep(xpos,each=lenypos) ypos<-rep(ypos,lenxpos) points(xpos,ypos,pch=pch[frect],cex=pch.cex[frect],col=pch.col[frect],...) } } plotrix/R/raw.means.plot.R0000744000176000001440000001715111747474173015224 0ustar ripleyusers # more explanatory name for the function raw.means.plot <-function(data, col.offset = 2, col.x = 3, col.value = 4, na.rm = FALSE, avoid.overlap = c("y", "x", "both"), y.factor = 1, y.amount = NULL, x.amount = 0.05, pch = 21:25, lty = 1:5, bg.b.col = "darkgrey", bg.f.col = NULL, fg.b.col = "black", fg.f.col = "black", type = "o", pt.cex = 1, lwd = 1, xlab = "", ylab = "", ylim, max.offset = 0.2, xaxis = TRUE, x.labels, xaxt = "n", plot = TRUE, legend = TRUE, mar = NULL, reset.mar = TRUE, l.pos, yjust = 0.5, l.bty = "n", l.adj = c(0, 0.5), ...) { # I somehow like more the idea of using random jitter. spread.out <- function(x, x.amount) { dupl <- duplicated(x) spreadx <- rep(0,length(x)) spreadx[dupl] <- jitter(spreadx[dupl], amount = x.amount) return(spreadx) } addJitter <- function (x, y.factor, y.amount) { dupl <- duplicated(x) x[dupl] <- jitter(x[dupl], factor = y.factor, amount = y.amount) return(x) } # I personally more like the spreading on the y-axis, but I totally agree that # spacing on the x-axis is also totally reasonable. create.dp <- function(lst, n.x, avoid.overlap, y.factor, y.amount, x.amount) { ret <- vector("list", 2) #browser() if (avoid.overlap[1] %in% c("x", "both")) ret[[1]] <- rep(1:n.x, vapply(lst, length, 0)) + unlist(lapply(lst, spread.out, x.amount = x.amount)) else ret[[1]] <- rep(1:n.x, vapply(lst, length, 0)) if (avoid.overlap[1] %in% c("y", "both")) ret[[2]] <- unlist(lapply(lst, addJitter, y.factor=y.factor, y.amount = y.amount)) else ret[[2]] <- unlist(lst) return(ret) } largs <- c("fill", "border", "angle", "density", "box.lwd", "box.lty", "box.col", "pt.lwd", "xjust", "x.intersp", "y.intersp", "text.width", "text.col", "merge", "trace", "plot", "ncol", "horiz", "title", "inset", "title.col", "title.adj") dots <- list(...) args.to.l <- dots[names(dots) %in% largs] args.to.p <- dots[!(names(dots) %in% largs)] if (!is.data.frame(data)) stop("data must be a data.frame") # I used "any" here as it seems more straightforward # I notice that you used it in add.ps if (any(is.na(data[, c(col.offset, col.x)]))) warning("NAs in offset or x column (this produces other warnings).") # as above if (na.rm == FALSE) if (any(is.na(data[, c(col.value)]))) stop("NAs in data column. Try: na.rm = TRUE") if (!is.factor(data[, col.offset])) { warning(paste("Converting offset variable (column ", col.offset, ") to factor.", sep = "")) data[, col.offset] <- factor(data[, col.offset]) } if (!is.factor(data[, col.x])) { warning(paste("Converting x-axis variable (column ", col.offset, ") to factor.", sep = "")) data[, col.x] <- factor(data[, col.x]) } if ((length(levels(data[, col.x])) != length(unique(data[, col.x])))) { warning(paste("Refactoring x-axis variable (column ", col.x, ") due to length mismatch.", sep = "")) data[, col.x] <- factor(data[, col.x]) } if ((length(levels(data[, col.offset])) != length(unique(data[, col.offset])))) { warning(paste("Refactoring offset variable (column ", col.offset, ") due to length mismatch.", sep = "")) data[, col.offset] <- factor(data[, col.offset]) } if (missing(ylim)) { # I think that range is equivalent to c(min,max) here ylim <- range(data[, col.value], na.rm = na.rm) warning(paste("ylim not specified, taken from data: ", ylim[1], " - ", ylim[2], sep = "")) } n.offset <- length(levels(data[, col.offset])) n.x <- length(levels(data[, col.x])) if (!(missing(x.labels))) { if (length(x.labels) < n.x) { warning("x.labels too short, taking unique(data[,col.x]) as labels at x-axis ticks") x.labels <- levels(data[, col.x]) } } while (length(pch) < n.offset) { warning("pch vector too short. recycling pch vector.") # this makes sure that the pch vector will be long enough pch <- rep(pch, length.out=n.offset) } while (length(lty) < n.offset) { warning("lty vector too short. recycling lty vector.") # ditto for the line type lty <- rep(lty, length.out=n.offset) } if (missing(x.labels)) { x.labels <- levels(data[, col.x]) } orig.mar <- par("mar") if (legend == TRUE & is.null(mar)) { mar <- orig.mar max.l <- max(nchar(levels(data[, col.offset]))) if (max.l < 3) rb <- 4.2 else if (max.l > 2 & max.l < 5) rb <- 5 else if (max.l > 4 & max.l < 7) rb <- 6 else if (max.l > 6 & max.l < 9) rb <- 7 else rb <- 8 mar[4] <- rb + 0.1 } if (!plot) mar <- c(0, 0, 0, 0) if (!is.null(mar)) res.mar <- par(mar = mar) nd <- split(data, data[, col.offset]) if (plot) { do.call("plot", c(list(x = 1, y = 2, xlim = c((1 - max.offset - 0.2), (n.x + max.offset + 0.2)), ylim = ylim, xaxt = xaxt, type = "n", xlab = xlab, ylab = ylab), args.to.p)) if (n.offset > 1) { offset.start <- max.offset - ((1 - (n.offset%%2)) * (max.offset/n.offset)) offset.dist <- max.offset/((n.offset - (n.offset%%2))/2) } if (n.offset == 1) { offset.start <- 0 offset.dist <- 0 } for (c in 1:n.offset) { d.c <- nd[[c]] d.lst <- split(d.c[, col.value], d.c[, col.x]) dp <- create.dp(lst = d.lst, n.x = n.x, avoid.overlap = avoid.overlap, y.factor = y.factor, y.amount = y.amount, x.amount = x.amount) x <- dp[[1]] - ((offset.start) - ((c - 1) * offset.dist)) y <- dp[[2]] points(x, y, pch = pch[c], col = bg.b.col, bg = bg.f.col, cex = pt.cex) } for (c in 1:n.offset) { d.c <- nd[[c]] d.lst <- split(d.c[, col.value], d.c[, col.x]) x <- 1:n.x - ((offset.start) - ((c - 1) * offset.dist)) y <- vapply(d.lst, mean, 0, na.rm = na.rm) lines(x, y, pch = pch[c], type = type, lty = lty[c], col = fg.b.col, bg = fg.f.col, cex = pt.cex, lwd = lwd) } if (xaxis == TRUE) axis(side = 1, at = 1:n.x, labels = x.labels) } if (!plot) { plot(0, 0, type = "n", xlim = c(0, 10), ylim = c(0, 10), axes = FALSE, ylab = "", xlab = "", mar = c(0, 0, 0, 0)) if (missing(l.pos)) l.pos = c(5, 5) } if (legend == TRUE) { if (n.x == 1) { if (missing(l.pos)) { l.pos <- (n.x + 0.45) l.pos[2] <- (ylim[2] - ((ylim[2] - ylim[1])/2)) } lty <- NULL } else (if (missing(l.pos)) { l.pos <- (n.x + max.offset + 0.4) l.pos[2] <- (ylim[2] - ((ylim[2] - ylim[1])/2)) }) do.call("legend", c(list(x = l.pos[1], y = l.pos[2], levels(data[, col.offset]), pch = pch, lty = lty, col = fg.b.col, pt.bg = fg.f.col, yjust = yjust, bty = l.bty, adj = l.adj, xpd = TRUE, pt.cex = pt.cex, lwd = lwd), args.to.l)) } if (legend == TRUE & reset.mar == TRUE) { par(mar = res.mar) } } plotrix/R/radialtext.R0000644000176000001440000000402211762116612014471 0ustar ripleyusersradialtext <- function(x, center=c(0,0), start=NA, middle=1, end=NA, angle=0, deg=NA, expand=0, stretch=1, nice=TRUE, cex=NA, ...) { oldcex <- par("cex") if (is.na(cex)) cex <- oldcex par(cex=cex) if (is.na(deg)) deg <- angle*180/pi deg <- deg %% 360 chardeg <- deg if (nice && (deg > 90 && deg < 270)) { chardeg <- (deg + 180) %% 360 x <- paste(rev(unlist(strsplit(x, ""))),collapse="") } angle <- deg*pi/180 xvec <- strsplit(x, "")[[1]] lenx <- length(xvec) xwidths <- stretch * strwidth(xvec) xwrange <- range(xwidths) xwidths[xwidths < xwrange[2]/2] <- xwrange[2]/2 # Make really narrow characters wider # Compute expand factor for each character and adjust character widths accordingly. chexp <- rep(1, lenx) if (!is.na(start) && expand != 0) { # Note: width of each char changes in succession, affecting sizes AND positions. expfactor <- expand/start deltar <- 0 for (xchar in 2:lenx) { deltar <- deltar + xwidths[xchar-1] expansion <- 1+deltar*expfactor if (expansion < 0.1) expansion <- 0.1 chexp[xchar] <- expansion xwidths[xchar] <- xwidths[xchar]*expansion } } # Find start distance if (is.na(start)) { if (is.na(end)) start <- middle - sum(xwidths)/2 else start <- end - sum(xwidths) } cosang <- cos(angle) sinang <- sin(angle) charstart <- c(start, start + cumsum(xwidths)[-lenx]) charpos <- charstart + xwidths/2 xylim <- par("usr") plotdim <- par("pin") ymult <- (xylim[4] - xylim[3])/(xylim[2] - xylim[1]) * plotdim[1]/plotdim[2] for (xchar in 1:lenx) { par(cex=cex*chexp[xchar]) text(center[1] + charpos[xchar] * cosang, center[2] + charpos[xchar] * ymult * sinang, xvec[xchar], adj=c(0.5, 0.5), srt=chardeg, ...) } par(cex=oldcex) } plotrix/R/radial.plot.labels.R0000755000176000001440000000160211371512244016003 0ustar ripleyusersradial.plot.labels<-function(lengths,radial.pos=NULL,units="radians", radial.lim=NULL,start=0,clockwise=FALSE,labels,adj=NULL,pos=NULL,...) { npoints<-length(lengths) if(is.null(radial.pos)) radial.pos<-seq(0,pi*(2-2/npoints),length.out=npoints) else { # clock24 starts at "midnight" and always runs clockwise if(units == "clock24") radial.pos<-pi*(450-radial.pos*15)/180 # polar starts at 3 o'clock and runs counterclockwise by default if(units == "polar") radial.pos<-pi*radial.pos/180 } if(clockwise && units != "clock24") radial.pos<--radial.pos if(start && units != "clock24") radial.pos<-radial.pos+start if(is.null(radial.lim)) radial.lim<-range(lengths) lengths<-lengths-radial.lim[1] # get the vector of x positions xpos<-cos(radial.pos)*lengths # get the vector of y positions ypos<-sin(radial.pos)*lengths text(x=xpos,y=ypos,labels=labels,adj=adj,pos=pos,...) } plotrix/R/radial.plot.R0000755000176000001440000002006212115620663014545 0ustar ripleyusers# plots data as radial lines or a polygon on a 24 hour "clockface" going # clockwise. clock.pos should be in decimal hours between 0 and 24. # Remember to convert hour/minute values to hour/decimal values. # example: clock24.plot(rnorm(16)+3,seq(5.5,20.5,length.out=16)) clock24.plot<-function(lengths,clock.pos,labels=NULL,label.pos=NULL, rp.type="r",...) { npos<-length(lengths) # if no positions are given, spread the lines out over the circle if(missing(clock.pos)) clock.pos<-seq(0,24-24/(npos+1),length=npos) # start at "midnight" and go clockwise radial.pos<-pi*(450-clock.pos*15)/180 if(is.null(labels)) labels<-paste(0:23,"00",sep="") if(is.null(label.pos)) label.pos<-seq(5*pi/2,7*pi/12,by=-pi/12) else label.pos<-pi*(450-clock.pos*15)/180 invisible(radial.plot(lengths,radial.pos,labels=labels,label.pos=label.pos, rp.type=rp.type,...)) } # plots data as radial lines or a polygon starting at the right and going # counterclockwise. # angles should be given in 0-360 values, use radial.plot for radians # example: polar.plot(rnorm(20)+3,seq(90,280,by=10)) polar.plot<-function(lengths,polar.pos=NULL,labels,label.pos=NULL, start=0,clockwise=FALSE,rp.type="r",...) { npos<-length(lengths) # if no positions are given, add the average distance between positions so that # the first and last line don't overlap if(is.null(polar.pos)) radial.pos<-seq(0,(2-2/(npos+1))*pi,length=npos) else radial.pos<-pi*polar.pos/180 if(start) start<-pi*start/180 if(is.null(label.pos)) label.pos<-seq(0,1.89*pi,length=18) else label.pos<-pi*label.pos/180 if(missing(labels)) labels<-as.character(seq(0,340,by=20)) invisible(radial.plot(lengths,radial.pos,labels,label.pos,start=start, clockwise=clockwise,rp.type=rp.type,...)) } # plots radial lines of length 'lengths', symbols at 'lengths' from the # center or a polygon with corresponding vertices at 'radial.pos' in radians. # starts at the 'east' position and goes counterclockwise unless # the "start" and "clockwise" arguments are changed # label.prop is the proportion of max(lengths) that gives the # radial position of the labels radial.plot<-function(lengths,radial.pos=NULL,labels=NA,label.pos=NULL,radlab=FALSE, start=0,clockwise=FALSE,rp.type="r",label.prop=1.15,main="",xlab="",ylab="", line.col=par("fg"),lty=par("lty"),lwd=par("lwd"),mar=c(2,2,3,2), show.grid=TRUE,show.grid.labels=4,show.radial.grid=TRUE, grid.col="gray",grid.bg="transparent",grid.left=FALSE,grid.unit=NULL, point.symbols=NULL,point.col=NULL,show.centroid=FALSE,radial.lim=NULL, radial.labels=NULL,boxed.radial=TRUE,poly.col=NULL,add=FALSE,...) { if(is.null(radial.lim)) radial.lim<-range(lengths) length.dim<-dim(lengths) if(is.null(length.dim)) { npoints<-length(lengths) nsets<-1 lengths<-matrix(lengths,nrow=1) } else { npoints<-length.dim[2] nsets<-length.dim[1] lengths<-as.matrix(lengths) } lengths<-lengths-radial.lim[1] lengths[lengths<0]<-NA if(is.null(radial.pos[1])) radial.pos<-seq(0,pi*(2 - 2 * (rp.type != "l")/npoints),length.out=npoints) radial.pos.dim<-dim(radial.pos) if(is.null(radial.pos.dim)) radial.pos<-matrix(rep(radial.pos,nsets),nrow=nsets,byrow=TRUE) else radial.pos<-as.matrix(radial.pos) if(rp.type == "l") { clockwise<-TRUE start<-pi/2 } if(clockwise) radial.pos<--radial.pos if(start) radial.pos<-radial.pos+start if(show.grid) { if(length(radial.lim) < 3) grid.pos<-pretty(radial.lim) else grid.pos<-radial.lim if(grid.pos[1] < radial.lim[1]) grid.pos<-grid.pos[-1] maxlength<-max(grid.pos-radial.lim[1]) angles<-seq(0,1.96*pi,by=0.04*pi) } else { grid.pos<-NA maxlength<-diff(radial.lim) } oldpar<-par("xpd","mar","pty") if(!add) { par(mar=mar,pty="s") plot(c(-maxlength,maxlength),c(-maxlength,maxlength),type="n",axes=FALSE, main=main,xlab=xlab,ylab=ylab) if(show.grid) { for(i in seq(length(grid.pos),1,by=-1)) { xpos<-cos(angles)*(grid.pos[i]-radial.lim[1]) ypos<-sin(angles)*(grid.pos[i]-radial.lim[1]) polygon(xpos,ypos,border=grid.col,col=grid.bg) } } } par(xpd=TRUE) # stretch everything out to the correct length if(length(line.col) < nsets) line.col<-1:nsets if(length(rp.type) < nsets) rp.type<-rep(rp.type,length.out=nsets) if(length(point.symbols) < nsets) point.symbols<-rep(point.symbols,length.out=nsets) if(length(point.col) < nsets) point.col<-rep(point.col,length.out=nsets) if(length(poly.col) < nsets) poly.col<-rep(poly.col,length.out=nsets) if(length(lty) < nsets) lty<-rep(lty,length.out=nsets) if(length(lwd) < nsets) lwd<-rep(lwd,length.out=nsets) for(i in 1:nsets) { if(nsets > 1) { linecol<-line.col[i] polycol<-poly.col[i] pointcol<-point.col[i] pointsymbols<-point.symbols[i] ltype<-lty[i] lwidth<-lwd[i] } else { linecol<-line.col polycol<-poly.col pointcol<-point.col pointsymbols<-point.symbols ltype<-lty lwidth<-lwd } # split up rp.type if there is a combination of displays rptype<-unlist(strsplit(rp.type[i],"")) if(match("s",rptype,0)) { if(is.null(pointsymbols)) pointsymbols<-i if(is.null(pointcol)) pointcol<-i } # get the vector of x positions xpos<-cos(radial.pos[i,])*lengths[i,] # get the vector of y positions ypos<-sin(radial.pos[i,])*lengths[i,] # plot radial lines if rp.type == "r" if(match("r",rptype,0)) segments(0,0,xpos,ypos,col=linecol,lty=ltype,lwd=lwidth,...) if(match("p",rptype,0)) polygon(xpos,ypos,border=linecol,col=polycol,lty=ltype, lwd=lwidth,...) if(match("s",rptype,0)) points(xpos,ypos,pch=pointsymbols,col=pointcol,...) if(match("l",rptype,0)) lines(xpos,ypos,lty=ltype,lwd=lwidth,col=linecol,...) if(show.centroid) if(match("p",rptype,0)) { nvertices<-length(xpos) # first get the "last to first" area component polygonarea<-xpos[nvertices]*ypos[1] - xpos[1]*ypos[nvertices] for(vertex in 1:(nvertices-1)) polygonarea<- polygonarea+xpos[vertex]*ypos[vertex+1]-xpos[vertex+1]*ypos[vertex] polygonarea<-polygonarea/2 centroidx<- (xpos[nvertices]+xpos[1])*(xpos[nvertices]*ypos[1]-xpos[1]*ypos[nvertices]) centroidy<- (ypos[nvertices]+ypos[1])*(xpos[nvertices]*ypos[1]-xpos[1]*ypos[nvertices]) for(vertex in 1:(nvertices-1)) { centroidx<-centroidx + (xpos[vertex]+xpos[vertex+1])* (xpos[vertex]*ypos[vertex+1]-xpos[vertex+1]*ypos[vertex]) centroidy<-centroidy + (ypos[vertex]+ypos[vertex+1])* (xpos[vertex]*ypos[vertex+1]-xpos[vertex+1]*ypos[vertex]) } points(centroidx/(6*polygonarea),centroidy/(6*polygonarea), col=point.col[i],pch=point.symbols[i],cex=2,...) } else points(mean(xpos),mean(ypos),col=pointcol,pch=pointsymbols, cex=2,...) } if(!add) { if(is.na(labels[1])) { label.pos<-seq(0,1.8*pi,length=9) labels<-as.character(round(label.pos,2)) } if(is.null(label.pos[1])) { lablen<-length(labels) label.pos<-seq(0,pi*(2-2/lablen),length.out=lablen) } if(clockwise) label.pos<--label.pos if(start) label.pos<-label.pos+start xpos<-cos(label.pos)*maxlength ypos<-sin(label.pos)*maxlength if(show.radial.grid) segments(0,0,xpos,ypos,col=grid.col) xpos<-cos(label.pos)*maxlength*label.prop ypos<-sin(label.pos)*maxlength*label.prop if(radlab) { for(label in 1:length(labels)) { labelsrt<-(180*label.pos[label]/pi)+ 180*(label.pos[label] > pi/2 && label.pos[label] < 3*pi/2) text(xpos[label],ypos[label],labels[label],cex=par("cex.axis"),srt=labelsrt) } } else boxed.labels(xpos,ypos,labels,ypad=0.7,border=FALSE,cex=par("cex.axis")) if(show.grid.labels) { if(show.grid.labels%%2) { ypos<-grid.pos-radial.lim[1] xpos<-rep(0,length(grid.pos)) if(show.grid.labels==1) ypos<--ypos } else { xpos<-grid.pos-radial.lim[1] ypos<-rep(0,length(grid.pos)) if(show.grid.labels==2) xpos<--xpos } if(is.null(radial.labels)) radial.labels=as.character(grid.pos) if(!is.null(grid.unit)) radial.labels[length(grid.pos)]<- paste(radial.labels[length(grid.pos)],grid.unit) if(boxed.radial) boxed.labels(xpos,ypos,radial.labels,border=FALSE, cex=par("cex.lab")) else text(xpos,ypos,radial.labels,cex=par("cex.lab")) } } invisible(oldpar) } plotrix/R/radial.pie.R0000644000176000001440000001264611726063071014353 0ustar ripleyusersdrawSectorAnnulus<-function(angle1,angle2,radius1,radius2,col,angleinc=0.03) { if(angle1 > angle2) { temp<-angle1 angle1<-angle2 angle2<-temp } if(radius1 > radius2) { temp<-radius1 radius1<-radius2 radius2<-temp } angles<-seq(angle1,angle2,by=angleinc) angles[length(angles)]<-angle2 xpos<-c(cos(angles)*radius1,cos(rev(angles))*radius2) ypos<-c(sin(angles)*radius1,sin(rev(angles))*radius2) polygon(xpos,ypos,col=col,border=col) } radial.grid<-function(labels=NA,label.pos=NULL,radlab=FALSE,radial.lim=NULL, start=0,clockwise=FALSE,label.prop=1.15,grid.pos, grid.col="gray",grid.bg="transparent") { par(xpd=TRUE) angles<-seq(0,1.96*pi,by=0.04*pi) for(i in seq(length(grid.pos),1,by=-1)) { xpos<-cos(angles)*(grid.pos[i]-radial.lim[1]) ypos<-sin(angles)*(grid.pos[i]-radial.lim[1]) polygon(xpos,ypos,border=grid.col,col=grid.bg) } if(is.na(labels[1])) { label.pos<-seq(0,1.8*pi,length=9) labels<-as.character(round(label.pos,2)) } if(is.null(label.pos[1])) { lablen<-length(labels) label.pos<-seq(0,pi*(2-2/lablen),length.out=lablen) } maxlength<-max(radial.lim)*1.05 if(clockwise) { label.pos<--label.pos labels<-rev(labels) } if(start) label.pos<-label.pos+start xpos<-cos(label.pos)*maxlength ypos<-sin(label.pos)*maxlength segments(0,0,xpos,ypos,col=grid.col) xpos<-cos(label.pos)*maxlength*label.prop ypos<-sin(label.pos)*maxlength*label.prop if(radlab) { for(label in 1:length(labels)) { labelsrt<-(180*label.pos[label]/pi)+ 180*(label.pos[label] > pi/2 && label.pos[label] < 3*pi/2) text(xpos[label],ypos[label],labels[label],cex=par("cex.axis"),srt=labelsrt) } } else boxed.labels(xpos,ypos,labels,ypad=0.7,border=FALSE,cex=par("cex.axis")) } # plots sectors composed of one or more sectors of annuli on a circular grid. # radial.extents are the radial extents of the sectors (a vector), # optionally with sub-extents that define the annuli # (a matrix with each sector a column) # sector.edges are the positions of the radii that define the sectors, # defaulting to n equal sectors filling the circle where # n is the number of radial extents. # sector.values are the values in each sector of an annulus that # will be represented by colors and must be the same data type and # dimension as radial.extents. # If a list of sector colors is passed, it will take precedence # and sector.colors will not be scaled from sector.values radial.pie<-function(radial.extents,sector.edges=NULL, sector.colors=NULL,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1),alpha=1, labels=NA,label.pos=NULL,radlab=FALSE,start=0,clockwise=FALSE,label.prop=1.15, radial.lim=NULL,main="",xlab="",ylab="",mar=c(2,2,3,2), show.grid=TRUE,show.grid.labels=4,show.radial.grid=TRUE, grid.col="gray",grid.bg="transparent",grid.left=FALSE,grid.unit=NULL, radial.labels=NULL,boxed.radial=TRUE, add=FALSE,...) { if(is.null(radial.lim)) radial.lim<-range(radial.extents) if(is.null(sector.edges)) { if(clockwise) sector.edges<-seq(2*pi+start,start,length.out=length(radial.extents)+1) else sector.edges<-seq(start,2*pi+start,length.out=length(radial.extents)+1) } if(is.null(label.pos)) label.pos<-sector.edges[-length(sector.edges)]+diff(sector.edges)/2 if(show.grid) { if(length(radial.lim) < 3) grid.pos<-pretty(radial.lim) else grid.pos<-radial.lim if(grid.pos[1] < radial.lim[1]) grid.pos<-grid.pos[-1] maxlength<-max(grid.pos-radial.lim[1]) } else { grid.pos<-NA maxlength<-diff(radial.lim) } oldpar<-par("xpd","mar","pty") if(!add) { par(mar=mar,pty="s") maxrad<-max(unlist(radial.extents)) plot(0,xlim=c(-maxrad,maxrad),ylim=c(-maxrad,maxrad),type="n",axes=FALSE) if(show.grid) radial.grid(labels=labels,label.pos=label.pos,radlab=radlab, radial.lim=radial.lim,start=start,clockwise=clockwise, label.prop=label.prop,grid.pos=grid.pos, grid.col=grid.col,grid.bg=grid.bg) } fadeColor<-function(col,nfades) { rgbcol<-col2rgb(col) redinc<-(255-rgbcol[1])/nfades reds<-(rgbcol[1]+0:nfades*redinc)/255 greeninc<-(255-rgbcol[2])/nfades greens<-(rgbcol[2]+0:nfades*greeninc)/255 blueinc<-(255-rgbcol[3])/nfades blues<-(rgbcol[3]+0:nfades*blueinc)/255 return(rgb(reds[1:nfades],greens[1:nfades],blues[1:nfades])) } nsectors<-length(radial.extents) if(is.list(radial.extents)) { if(is.null(sector.colors)) sector.colors<-rainbow(nsectors) for(sector in 1:nsectors) { annuli<-radial.extents[[sector]] annulus.colors<-fadeColor(sector.colors[[sector]],length(annuli)) for(annulus in 1:(length(annuli)-1)) { drawSectorAnnulus(sector.edges[[sector]],sector.edges[[sector+1]], annuli[annulus],annuli[annulus+1],annulus.colors[annulus]) } } } else { if(is.null(sector.colors)) sector.colors<-rainbow(nsectors) for(sector in 1:nsectors) { drawSectorAnnulus(sector.edges[sector],sector.edges[sector+1], 0,radial.extents[sector],sector.colors[sector]) } } if(show.grid.labels) { if(show.grid.labels%%2) { ypos<-grid.pos-radial.lim[1] xpos<-rep(0,length(grid.pos)) if(show.grid.labels==1) ypos<--ypos } else { xpos<-grid.pos-radial.lim[1] ypos<-rep(0,length(grid.pos)) if(show.grid.labels==2) xpos<--xpos } if(is.null(radial.labels)) radial.labels<-grid.pos if(!is.null(grid.unit)) radial.labels[length(grid.pos)]<- paste(radial.labels[length(grid.pos)],grid.unit) if(boxed.radial) boxed.labels(xpos,ypos,radial.labels,border=FALSE, cex=par("cex.lab")) else text(xpos,ypos,radial.labels,cex=par("cex.lab")) } invisible(oldpar) } plotrix/R/pyramid.plot.R0000755000176000001440000000652312132127360014757 0ustar ripleyuserspyramid.plot<-function(lx,rx,labels=NA,top.labels=c("Male","Age","Female"), main="",laxlab=NULL,raxlab=NULL,unit="%",lxcol,rxcol,gap=1,ppmar=c(4,2,4,2), labelcex=1,add=FALSE,xlim,show.values=FALSE,ndig=1,do.first=NULL) { xdim<-length(dim(lx)) if(missing(rx) && xdim > 0) { rx<-lx[,2] lx<-lx[,1] } if(any(c(lx,rx)<0,na.rm=TRUE)) stop("Negative quantities not allowed") ncats<-ifelse(xdim,dim(lx)[1],length(lx)) if(length(labels)==1) labels<-1:ncats ldim<-length(dim(labels)) nlabels<-ifelse(ldim,length(labels[,1]),length(labels)) if(nlabels != ncats) stop("lx and labels must all be the same length") if(missing(xlim)) xlim<-rep(ifelse(xdim,ceiling(max(c(rowSums(lx),rowSums(rx)),na.rm=TRUE)), ceiling(max(c(lx,rx),na.rm=TRUE))),2) if(!is.null(laxlab) && xlim[1] < max(laxlab)) xlim[1]<-max(laxlab) if(!is.null(raxlab) && xlim[2] < max(raxlab)) xlim[2]<-max(raxlab) oldmar<-par("mar") if(!add) { par(mar=ppmar,cex.axis=labelcex) # create an empty plot plot(0,xlim=c(-(xlim[1]+gap),xlim[2]+gap),ylim=c(0,ncats+1), type="n",axes=FALSE,xlab="",ylab="",xaxs="i",yaxs="i",main=main) if(!is.null(do.first)) eval(do.first) # add the bottom axes if(is.null(laxlab)) { laxlab<-seq(xlim[1]-gap,0,by=-1) axis(1,at=-xlim[1]:-gap,labels=laxlab) } else axis(1,at=-(laxlab+gap),labels=laxlab) if(is.null(raxlab)) { raxlab<-0:(xlim[2]-gap) axis(1,at=gap:xlim[2],labels=raxlab) } else axis(1,at=raxlab+gap,labels=raxlab) if(gap > 0) { if(xdim) axis(2,at=1:ncats,labels=rep("",ncats),pos=gap,tcl=-0.25) else axis(2,at=1:ncats * as.logical(rx+1),labels=rep("",ncats),pos=gap, tcl=-0.25) if(xdim) axis(4,at=1:ncats,labels=rep("",ncats),pos=gap,tcl=-0.25) else axis(4,at=1:ncats * as.logical(lx+1),labels=rep("",ncats),pos=gap, tcl=-0.25) } # display the category labels if(is.null(dim(labels))) { if(gap) text(0,1:ncats,labels,cex=labelcex) else { text(xlim[1],1:ncats,labels,cex=labelcex,adj=0) text(xlim[2],1:ncats,labels,cex=labelcex,adj=1) } } else { if(gap) { lpos<--gap rpos<-gap } else { lpos<--xlim[1] rpos<-xlim[2] } text(lpos,1:ncats,labels[,1],pos=4,cex=labelcex,adj=0) text(rpos,1:ncats,labels[,2],pos=2,cex=labelcex,adj=1) } # display the top or bottom labels mtext(top.labels,3,0,at=c(-xlim[1]/2,0,xlim[2]/2),adj=0.5,cex=labelcex) mtext(c(unit,unit),1,2,at=c(-xlim[1]/2,xlim[2]/2)) } if(xdim == 0) { if(missing(lxcol)) lxcol<-rainbow(ncats) if(missing(rxcol)) rxcol<-rainbow(ncats) rect(-(lx+gap),1:ncats-0.4,rep(-gap,ncats),1:ncats+0.4,col=lxcol) rect(rep(gap,ncats),1:ncats-0.4,(rx+gap),1:ncats+0.4,col=rxcol) if(show.values) { par(xpd=TRUE) text(-(gap+lx),1:ncats,round(lx,ndig),pos=2,cex=labelcex) text(gap+rx,1:ncats,round(rx,ndig),pos=4,cex=labelcex) par(xpd=FALSE) } } else { nstack<-dim(lx)[2] if(missing(lxcol)) lxcol <- rainbow(nstack) if(missing(rxcol)) rxcol <- rainbow(nstack) lxstart<-rxstart<-rep(gap,ncats) for(i in 1:nstack) { lxcolor<-rep(lxcol[i],ncats) rxcolor<-rep(rxcol[i],ncats) rect(-(lx[,i]+lxstart),1:ncats-0.4,-lxstart,1:ncats+0.4,col=lxcolor) rect(rxstart,1:ncats-0.4,rx[,i]+rxstart,1:ncats+0.4,col=rxcolor) lxstart<-lx[,i]+lxstart rxstart<-rx[,i]+rxstart } } return(oldmar) } plotrix/R/polygon.shadow.R0000755000176000001440000000123011056465626015314 0ustar ripleyuserspolygon.shadow<-function(x,y=NULL,offset=NA,inflate=NA, col=c("#ffffff","#cccccc")) { if(is.null(y)) { if(is.null(x$y)) stop("both x and y coordinates must be given") y<-x$y x<-x$x } xcenter<-mean(x) ycenter<-mean(y) if(is.na(offset[1])) offset<-c((max(x)-min(x))/20,-(max(y)-min(y))/20) if(length(col) == 2) col<-smoothColors(col[1],8,col[2]) if(is.na(inflate[1])) { multx<-seq(offset[1],0,length=10) multy<-seq(offset[2],0,length=10) } else { multx<-seq(inflate[1],0,length=10) multy<-seq(inflate[2],0,length=10) } for(i in 1:10) polygon(x+multx[i]*(x-xcenter)+offset[1],y+multy[i]*(y-ycenter)+offset[2], col=col[i],border=NA) } plotrix/R/plotCI.R0000755000176000001440000000654411714160051013531 0ustar ripleyusersplotCI <- function (x, y = NULL, uiw, liw = uiw, ui = NULL, li = NULL, err = "y", sfrac = 0.01, gap = 0, slty = par("lty"), add = FALSE, scol = NULL, pt.bg = par("bg"), ...) { arglist <- list(...) if (is.list(x)) { y <- x$y x <- x$x } if (is.null(y)) { if (is.null(x)) stop("both x and y NULL") y <- as.numeric(x) x <- seq(along = x) } if (missing(uiw) && (is.null(ui) || is.null(li))) stop("must specify either relative limits or both lower and upper limits") if (!missing(uiw)) { if (err == "y") z <- y else z <- x ui <- z + uiw li <- z - liw } if (is.null(arglist$xlab)) arglist$xlab <- deparse(substitute(x)) if (is.null(arglist$ylab)) arglist$ylab <- deparse(substitute(y)) if (err == "y" && is.null(arglist$ylim)) arglist$ylim <- range(c(y, ui, li), na.rm = TRUE) if (err == "x" && is.null(arglist$xlim)) arglist$xlim <- range(c(x, ui, li), na.rm = TRUE) if (missing(scol)) { if (!is.null(arglist$col)) scol <- arglist$col else scol <- par("col") } plotpoints <- TRUE if (!is.null(arglist$pch) && is.na(arglist$pch)) { arglist$pch <- 1 plotpoints <- FALSE } if (!add) do.call("plot", c(list(x, y, type = "n"), clean.args(arglist, plot))) if (gap == TRUE) gap <- 0.01 ul <- c(li, ui) pin <- par("pin") usr <- par("usr") x.to.in <- pin[1]/diff(usr[1:2]) y.to.in <- pin[2]/diff(usr[3:4]) if (err == "y") { gap <- rep(gap, length(x)) * diff(par("usr")[3:4]) smidge <- par("fin")[1] * sfrac nz <- abs(li - pmax(y - gap, li)) * y.to.in > 0.001 scols <- rep(scol, length.out = length(x))[nz] arrow.args <- c(list(lty = slty, angle = 90, length = smidge, code = 1, col = scols), clean.args(arglist, arrows, exclude.other = c("col", "lty", "axes"))) do.call("arrows", c(list(x[nz], li[nz], x[nz], pmax(y - gap, li)[nz]), arrow.args)) nz <- abs(ui - pmin(y + gap, ui)) * y.to.in > 0.001 scols <- rep(scol, length.out = length(x))[nz] arrow.args$col <- scols do.call("arrows", c(list(x[nz], ui[nz], x[nz], pmin(y + gap, ui)[nz]), arrow.args)) } else if (err == "x") { gap <- rep(gap, length(x)) * diff(par("usr")[1:2]) smidge <- par("fin")[2] * sfrac nz <- abs(li - pmax(x - gap, li)) * x.to.in > 0.001 scols <- rep(scol, length.out = length(x))[nz] arrow.args <- c(list(lty = slty, angle = 90, length = smidge, code = 1, col = scols), clean.args(arglist, arrows, exclude.other = c("col", "lty", "axes"))) do.call("arrows", c(list(li[nz], y[nz], pmax(x - gap, li)[nz], y[nz]), arrow.args)) nz <- abs(ui - pmin(x + gap, ui)) * x.to.in > 0.001 scols <- rep(scol, length.out = length(x))[nz] arrow.args$col <- scols do.call("arrows", c(list(ui[nz], y[nz], pmin(x + gap, ui)[nz], y[nz]), arrow.args)) } if (plotpoints) do.call("points", c(list(x, y, bg = pt.bg), clean.args(arglist, points, exclude.other = c("xlab", "ylab", "xlim", "ylim", "axes")))) invisible(list(x = x, y = y)) } plotrix/R/pie3D.R0000755000176000001440000001103011745756531013307 0ustar ripleyuserspie3D.labels<-function(radialpos,radius=1,height=0.1,theta=pi/6, labels,labelcol=par("fg"),labelcex=1.5,labelrad=1.25,minsep=0.3){ oldcex<-par("cex") nlab<-length(labels) par(cex=labelcex,xpd=TRUE) for (i in 1:nlab) { if(i < nlab) { labelsep<-radialpos[i+1] - radialpos[i] if(labelsep < minsep) { radialpos[i]<-radialpos[i]+(labelsep-minsep)/2 radialpos[i+1]<-radialpos[i+1]-(labelsep-minsep)/2 } } xpos<-labelrad * radius * cos(radialpos[i]) offset<-(radialpos[i] > pi && radialpos[i] < 2 * pi) * height ypos<-labelrad * radius * sin(radialpos[i]) * 2 * theta/pi + sin(radialpos[i]) * height text(xpos,ypos,labels[i],col=labelcol, adj=c(0.5,abs(0.5-sin(radialpos[i])/2))) } par(cex=oldcex,xpd=FALSE) } draw.tilted.sector<-function(x=0,y=0,edges=NA,radius=1,height=0.1, theta=pi/6,start=0,end=pi*2,border=par("fg"),col=par("bg"),explode=0, shade=0.8) { if(is.na(edges)) edges<-trunc(20*(end-start)) angleinc<-(end-start)/edges angles<-c(seq(start,end,by=angleinc),end) viscurve<-(angles>=pi)&(angles<=2*pi) nv<-length(angles) bisector<-(start+end)/2 if(explode){ # calculate the x and y offsets for the explode x<-x+cos(bisector)*explode y<-y+sin(bisector)*(1-sin(theta))*explode } if(shade>0 && shade<1){ # calculate the shade color for the sides of the sector rgbcol<-col2rgb(col) shadecol<-rgb(shade*rgbcol[1]/255,shade*rgbcol[2]/255, shade*rgbcol[3]/255) } else shadecol<-col xp<-cos(angles) * radius + x # this is the top of the sector yp<-sin(angles) * 2 * theta/pi * radius + y if(start > 3*pi/2) { # the 'left' side will be visible in this quadrant if(explode > 0) # display the 'right' side just in case it goes beyond pi/2 polygon(c(xp[nv],x,x,xp[nv],xp[nv]),c(yp[nv]-height,y-height, y+height,yp[nv]+height,yp[nv]+height),border=border, col=shadecol) # display the 'outside' of the sector polygon(c(xp[viscurve],rev(xp[viscurve])),c(yp[viscurve]-height, rev(yp[viscurve])+height),border=border,col=shadecol) if(explode > 0) # display the 'left' (front) side polygon(c(xp[1],x,x,xp[1],xp[1]),c(yp[1]-height,y-height, y+height,yp[1]+height,yp[1]),border=border, col=shadecol) } else { if(start > pi/2) { if(explode > 0) { polygon(c(xp[1],x,x,xp[1],xp[1]),c(yp[1]-height,y-height, y+height,yp[1]+height,yp[1]),border=border, col=shadecol) polygon(c(xp[nv],x,x,xp[nv],xp[nv]),c(yp[nv]-height, y-height,y+height,yp[nv]+height,yp[nv]+height), border=border,col=shadecol) } if(end > pi) polygon(c(xp[viscurve],rev(xp[viscurve])),c(yp[viscurve]-height, rev(yp[viscurve])+height),border=border, col=shadecol) } else { if(end > pi || start<2*pi) polygon(c(xp[viscurve],rev(xp[viscurve])),c(yp[viscurve]-height, rev(yp[viscurve])+height),border=border, col=shadecol) if(end > pi/2 && end < 3*pi/2 && explode > 0){ polygon(c(xp[nv],x,x,xp[nv],xp[nv]),c(yp[nv]-height, y-height,y+height,yp[nv]+height,yp[nv]+height), border=border,col=shadecol) } if(explode > 0) polygon(c(xp[1],x,x,xp[1],xp[1]),c(yp[1]-height,y-height, y+height,yp[1]+height,yp[1]+height),border=border, col=shadecol) } } #display the top polygon(c(xp,x),c(yp+height,y+height),border=border,col=col) return(bisector) } pie3D<-function(x,edges=NA,radius=1,height=0.1,theta=pi/6, start=0,border=par("fg"),col=NULL,labels=NULL,labelpos=NULL, labelcol=par("fg"),labelcex=1.5,sector.order=NULL,explode=0, shade=0.8,mar=c(4,4,4,4),pty="s",...) { if(!is.numeric(x) || any(x < 0)) stop("pie3D: x values must be positive numbers") # drop zeros if(any(x == 0)) x<-x[x>0] # drop NAs if(any(is.na(x))) x<-x[!is.na(x)] oldmar<-par("mar") par(pty=pty,mar=mar,xpd=TRUE) x<-c(0, cumsum(x)/sum(x))*2*pi+start nsectors<-length(x)-1 if(is.null(col)) col <- rainbow(nsectors) else if(length(col) < nsectors) col<-rep(col,length.out=nsectors) if(is.null(sector.order)) # get the order of drawing sectors sector.order<- order(sin((x[2:(nsectors+1)]+x[1:nsectors])/2),decreasing=TRUE) bc<-rep(0,nsectors) # set up an empty plot plot(0,xlab="",ylab="",xlim=c(-1,1),ylim=c(-1,1),type="n",axes=FALSE,...) for(i in sector.order) { bc[i]<-draw.tilted.sector(radius=radius,height=height, theta=theta,start=x[i],end=x[i+1],edges=edges, border=border,col=col[i],explode=explode,shade=shade) } if(!is.null(labels)) { if(!is.null(labelpos)) bc<-labelpos pie3D.labels(bc,height=height,theta=theta, labels=labels,labelcol=labelcol,labelcex=labelcex) } par(mar=oldmar,xpd=FALSE,pty="m") invisible(bc) } plotrix/R/paxis3d.R0000755000176000001440000000740311432464136013715 0ustar ripleyusers## 'enhanced' persp -- return value has attributes containing ## x,y,z ranges perspx <- function(x,y,z,...) { if (missing(z)) { if (!missing(x)) { if (is.list(x)) { z <- x$z y <- x$y x <- x$x } else { z <- x x <- seq.int(0, 1, length.out = nrow(z)) } } else stop("no 'z' matrix specified") } else if (is.list(x)) { y <- x$y x <- x$x } p <- persp(x,y,z,...) attr(p,"ranges") <- list(x=range(x),y=range(y),z=range(z)) p } psegments3d <- function(x, y = NULL, z = NULL, pmat, ...) { if (is.null(y) && is.null(z)) { z <- x$z y <- x$y x <- x$x } xy <- trans3d(x,y,z,pmat) ## translate from 'segments3d' (successive pairs) to ## 'segments' (x0,x1,y0,y1) format n <- length(xy$x) x0 <- xy$x[seq(1,n,by=2)] x1 <- xy$x[seq(2,n,by=2)] y0 <- xy$y[seq(1,n,by=2)] y1 <- xy$y[seq(2,n,by=2)] segments(x0=x0,x1=x1,y0=y0,y1=y1,...) } ptext3d <- function(x, y = NULL, z = NULL, texts, pmat, ...) { if (is.null(y) && is.null(z)) { z <- x$z y <- x$y x <- x$x } do.call(text,c(trans3d(x,y,z,pmat),list(label=texts,...))) } if (FALSE) { pp <- persp(x=1:3,y=1:3,z=matrix(1:9,nrow=3),col="gray") ptext3d(2,2,5,"a",pp,col="red") } get_axispos3d <- function(edge,pmat,at,pos=NULL, dist=0) { ranges <- attr(pmat,"ranges") edge <- c(strsplit(edge, "")[[1]], "-", "-")[1:3] coord <- match(toupper(edge[1]), c("X", "Y", "Z")) if (coord == 2) edge[1] <- edge[2] else if (coord == 3) edge[1:2] <- edge[2:3] mpos <- matrix(NA, 3, length(at)) if (edge[1] == "+") mpos[1, ] <- ranges$x[2] else mpos[1, ] <- ranges$x[1] if (edge[2] == "+") mpos[2, ] <- ranges$y[2] else mpos[2, ] <- ranges$y[1] if (edge[3] == "+") mpos[3, ] <- ranges$z[2] else mpos[3, ] <- ranges$z[1] offset <- dist * (mpos[, 1] - c(mean(ranges$x), mean(ranges$y), mean(ranges$z))) offset[coord] <- 0 mpos <- sweep(mpos,1,offset,"+") if (!is.null(pos)) mpos <- matrix(pos, 3, length(at)) mpos[coord, ] <- at mpos } mtext3d <- function (edge, pmat, labels = TRUE, at = NULL, dist=0.3, xpd=NA, ...) { ranges <- attr(pmat,"ranges") edge.orig <- edge ## hack edge <- c(strsplit(edge, "")[[1]], "-", "-")[1:3] coord <- match(toupper(edge[1]), c("X", "Y", "Z")) range <- ranges[[coord]] if (is.null(at)) { at <- mean(range) } mpos <- get_axispos3d(edge.orig,pmat,at,dist=dist) ptext3d(mpos[1, ],mpos[2,],mpos[3,], labels, pmat, xpd=xpd, ...) } paxis3d <- function (edge, pmat, at = NULL, labels = TRUE, tick = TRUE, pos = NULL, nticks = 5, ticklen=0.05,labdist=0.15, xpd=NA, ...) { ranges <- attr(pmat,"ranges") edge.orig <- edge ## hack edge <- c(strsplit(edge, "")[[1]], "-", "-")[1:3] coord <- match(toupper(edge[1]), c("X", "Y", "Z")) range <- ranges[[coord]] if (is.null(at)) { at <- pretty(range, nticks) at <- at[at >= range[1] & at <= range[2]] } if (is.logical(labels)) { if (labels) labels <- format(at) else labels <- NA } mpos <- get_axispos3d(edge.orig,pmat,at,pos,dist=0) ## draw axes x <- c(mpos[1, 1], mpos[1, length(at)]) y <- c(mpos[2, 1], mpos[2, length(at)]) z <- c(mpos[3, 1], mpos[3, length(at)]) psegments3d(x,y,z,pmat, xpd=xpd, ...) if (tick) { mpos_tick <- get_axispos3d(edge.orig,pmat,at,dist=ticklen) x <- c(as.double(rbind(mpos[1, ], mpos_tick[1, ]))) y <- c(as.double(rbind(mpos[2, ], mpos_tick[2, ]))) z <- c(as.double(rbind(mpos[3, ], mpos_tick[3, ]))) psegments3d(x,y,z,pmat, xpd=xpd, ...) } if (!is.null(labels)) { mpos_lab <- get_axispos3d(edge.orig,pmat,at,dist=labdist) ptext3d(mpos_lab[1, ],mpos_lab[2,],mpos_lab[3,], labels, pmat, xpd=xpd, ...) } } plotrix/R/panes.R0000755000176000001440000000043611421543336013445 0ustar ripleyuserspanes<-function(mat=NULL,widths=rep(1,ncol(mat)),heights=rep(1,nrow(mat)), nrow=2,ncol=2,mar=c(0,0,1.6,0),oma=c(2.5,1,1,1)) { oldpar<-par("mar","mfrow","oma") if(is.null(mat)) par(mfrow=c(nrow,ncol),mar=mar,oma=oma) else layout(mat,widths=widths,heights=heights) return(oldpar) } plotrix/R/multsymbolbox.R0000755000176000001440000000065311056465626015271 0ustar ripleyusersmultsymbolbox<-function(x1,y1,x2,y2,tot,relw=0.8,fg=par("fg"),bg=par("bg"), box=TRUE,debug=FALSE,...) { x1 <- rep(x1, length(tot)) y1 <- rep(y1, length(tot)) x2 <- rep(x2, length(tot)) y2 <- rep(y2, length(tot)) fg <- rep(fg, length(tot)) bg <- rep(bg, length(tot)) for (i in 1:length(tot)) { if (tot[i] > 0) symbolbox(x1[i],y1[i],x2[i],y2[i],tot[i],relw=relw, fg=fg[i],bg=bg[i],box=box,debug=debug,...) } } plotrix/R/multhist.R0000755000176000001440000000205512112012050014165 0ustar ripleyusersmulthist <- function (x, beside=TRUE, freq=NULL, probability=!freq, plot.it=TRUE, ...) { ## sort out histogram arguments hist.args <- formals(hist.default) args <- list(...) hargs <- names(args)[names(args) %in% names(hist.args)] hist.args[hargs] <- args[hargs] hist.args$plot<-FALSE ## sort out barplot arguments barplot.args <- formals(barplot.default) bargs <- names(args)[names(args) %in% names(barplot.args)] barplot.args[bargs] <- args[bargs] barplot.args$beside <- beside ## prevent warnings barplot.args$"..." <- barplot.args$inside <- NULL allhist <- hist(unlist(x),hist.args$breaks,plot=FALSE) if (!"names.arg" %in% bargs) { barplot.args$names.arg <- signif(allhist$mids, 2) } if (is.null(freq)) { freq<-if(!missing(probability)) !as.logical(probability) else TRUE } if(freq) comp<-"counts" else comp<-"density" combhist <- t(sapply(x, function(z) hist(z,breaks=allhist$breaks,plot=FALSE)[[comp]])) if(plot.it) do.call("barplot", c(list(combhist),barplot.args)) invisible(list(allhist,combhist)) } plotrix/R/maxEmptyRect.R0000644000176000001440000000311711672061604014756 0ustar ripleyusers# function to find the largest rectangle not containing any of the points # specified by x and y # adapted by Hans Borchers from # A. Naamad, D. T. Lee, and W.-L. Hsu (1984). On the Maximum Empty # Rectangle Problem. Discrete Applied Mathematics, Vol. 8, pp. 267--277. maxEmptyRect <- function(ax, ay, x, y) { n <- length(x) d <- sort(c(ax, x)) D <- diff(d) m <- which.max(D) # check vertical slices mgap <- D[m] maxr <- mgap * (ay[2] - ay[1]) maxR <- c(d[m], ay[1], d[m+1], ay[2]) o <- order(y) X <- x[o]; Y <- y[o] for (i in 1:n) { tl <- ax[1]; tr <- ax[2] if (i < n) { for (j in (i+1):n) { if (X[j] > tl && X[j] < tr) { # check horizontal slices (j == i+1) # and (all) rectangles above (X[i], Y[i]) area <- (tr-tl)*(Y[j]-Y[i]) if (area > maxr) { maxr <- area maxR <- c(tl, Y[i], tr, Y[j]) } if (X[j] > X[i]) tr <- X[j] else tl <- X[j] } } } # check open rectangles above (X[i], Y[i]) area <- (tr-tl)*(ay[2]-Y[i]) if (area > maxr) { maxr <- area maxR <- c(tl, Y[i], tr, ay[2]) } } for (i in 1:n) { # check open rectangles above (X[i], Y[i]) ri <- min(ax[2], X[Y > Y[i] & X > X[i]]) li <- max(ax[1], X[Y > Y[i] & X < X[i]]) area <- (ri-li)*(ay[2]-Y[i]) if (area > maxr) { maxr <- area maxR <- c(li, Y[i], ri, ay[2]) } # check open rectangles below (X[i], Y[i]) ri <- min(ax[2], X[Y < Y[i] & X > X[i]]) li <- max(ax[1], X[Y < Y[i] & X < X[i]]) area <- (ri-li)*(Y[i]-ay[1]) if (area > maxr) { maxr <- area maxR <- c(li, ay[1], ri, Y[i]) } } return(list(area = maxr, rect = maxR)) } plotrix/R/makeIntersectList.R0000755000176000001440000000477311642564315016006 0ustar ripleyuserspasteCols<-function(x,sep="") { pastestring<-paste("list(",paste("x","[",1:dim(x)[1],",]", sep="",collapse=","),")",sep="") return(do.call(paste,c(eval(parse(text = pastestring)),sep=sep))) } # converts a two column matrix of object identifiers [,1] and attributes [,2] # into a data frame of TRUE/FALSE values where each row is an object and # each column is an attribute categoryReshape<-function(x) { dimx<-dim(x) if(is.null(dimx) || dimx[2]==1) stop("Can only reshape a matrix or data frame with at least two columns") row_values<-sort(unique(x[,1])) column_values<-sort(unique(x[,2])) newx<- as.data.frame(matrix(0,nrow=length(row_values),ncol=length(column_values))) for(row in 1:dimx[1]) { row_index<-which(row_values %in% x[row,1]) column_index<-which(column_values %in% x[row,2]) newx[row_index,column_index]<-1 } names(newx)<-column_values return(newx) } # makes an intersectList object from a matrix or data frame of TRUE/FALSE # values where each row represents an object and each column an attribute # TRUE indicates that the object has that attribute, FALSE that it does not # add a "weight" vector that allows a count of objects to be read directly makeIntersectList<-function(x,xnames=NULL,sep="+") { # If any entries in x are not 1/0 OR TRUE/FALSE, assume that x # is a two column matrix of object identifiers [,1] and attributes [,2] if(any(!(x %in% c(TRUE,FALSE)))) x<-categoryReshape(x) if(is.null(xnames)) xnames <- colnames(x) dimx<-dim(x) if(is.null(xnames)) xnames<-LETTERS[1:dimx[2]] intersectList<-vector("list",dimx[2]+2) for(intersect in 1:dimx[2]) intersectList[[1]][intersect]<-sum(rowSums(x)==1 & x[,intersect]) names(intersectList[[1]])<-xnames for(comb in 2:dimx[2]) { nn<-choose(dimx[2],comb) intersectList[[comb]]<-rep(0,nn) currentnames<- names(intersectList[[comb]])<-pasteCols(combn(xnames,comb),sep) currentcombs<-combn(1:dimx[2],comb,simplify=TRUE) for(intersect in 1:nn) { combvec<-rep(0,dimx[2]) combvec[currentcombs[,intersect]]<-1 intersectList[[comb]][intersect]<- sum(colSums(apply(x,1,"==",combvec))==dimx[2]) } } intersectList[[dimx[2]+1]]<-dimx[1] names(intersectList[[dimx[2] + 1]])<-"Total" intersectList[[dimx[2]+2]]<-xnames names(intersectList[[dimx[2] + 2]])<-"attributes" # drop any empty intersection levels for(comb in dimx[2]:1) if(sum(intersectList[[comb]])==0) intersectList[[comb]]<-NULL class(intersectList)<-"intersectList" return(intersectList) } plotrix/R/lengthKey.R0000755000176000001440000000053011056465626014275 0ustar ripleyuserslengthKey<-function(x,y,tickpos,scale) { par(xpd=TRUE) nticks<-length(tickpos) segments(x,y,x+tickpos[nticks]*scale,y) for(tick in 1:nticks) { segments(x+tickpos[tick]*scale,y, x+tickpos[tick]*scale,y+tickpos[nticks]*scale/20) text(x+tickpos[tick]*scale,y+tickpos[nticks]*scale/15, tickpos[tick],adj=c(0.5,0)) } par(xpd=FALSE) } plotrix/R/legendg.R0000755000176000001440000000422111332654712013742 0ustar ripleyuserslegendg<-function(x,y=NULL,legend,fill=NULL,col=par("col"), border="black",lty,lwd,pch=NULL,angle=45,density=NULL, bty="o",bg=par("bg"),box.lwd=par("lwd"),box.lty=par("lty"), box.col=par("fg"),pt.bg=NA,cex=1,pt.cex=cex,pt.lwd=lwd, pt.space=1,xjust=0,yjust=1,x.intersp=1,y.intersp=1, adj=c(0,0.5),text.width=NULL,text.col=par("col"),merge=FALSE, trace=FALSE,plot=TRUE,ncol=1,horiz=FALSE,title=NULL, inset=0,xpd,title.col=text.col) { if(missing(legend) && !is.null(y)) { legend<-y y<-NULL } if(is.list(x)) { y<-x$y x<-x$x } if(!missing(xpd)) { oldxpd<-par("xpd") par(xpd=xpd) } legend.info<-legend(x=x,y=y,legend=legend,col=par("bg"),lty=1, bty=bty,bg=bg,box.lwd=box.lwd,box.lty=box.lty, box.col=par("fg"),pt.bg=NA,cex=1,pt.cex=pt.cex,pt.lwd=pt.lwd, xjust=xjust,yjust=yjust,x.intersp=x.intersp,y.intersp=y.intersp, adj=adj,text.width=text.width,text.col=text.col,merge=merge, trace=trace,plot=plot,ncol=ncol,horiz=horiz,title=title, inset=inset,title.col=title.col) if(!is.null(fill)) { rectheight<-strheight("Q") if(length(adj) > 1) yadj<-adj[2] else yadj<-0.5 for(nel in 1:length(fill)) { nrect<-length(fill[[nel]]) rectspace<-(legend.info$text$x[nel]-legend.info$rect$left) lefts<-cumsum(c(legend.info$rect$left+rectspace*0.1, rep(0.8*rectspace/nrect,nrect-1))) rights<-lefts+0.7*rectspace/nrect bottoms<-rep(legend.info$text$y[nel]-yadj*rectheight,nrect) rect(lefts,bottoms,rights,bottoms+rectheight,col=fill[[nel]], border=ifelse(is.na(fill[[nel]]),par("bg"),par("fg"))) } } if(!is.null(pch)) { if(!is.list(col)) { mycol<-pch if(length(col) < length(mycol[[1]])) col<-rep(col,length.out=length(mycol[[1]])) for(nel in 1:length(col)) mycol[[nel]]<-rep(col,length.out=length(mycol[[nel]])) } else mycol<-col pchwidth<-strwidth("O",cex=pt.cex) for(nel in 1:length(pch)) { npch<-length(pch[[nel]]) xpos<-cumsum(c(legend.info$text$x[nel]-pchwidth, rep(-pchwidth*pt.space,npch-1))) ypos<-rep(legend.info$text$y[nel],npch) points(xpos,ypos,pch=pch[[nel]],col=mycol[[nel]],cex=pt.cex) } } if(!missing(xpd)) par(xpd=oldxpd) invisible(legend.info) } plotrix/R/ladderplot.default.R0000755000176000001440000000301311471167006016107 0ustar ripleyusersladderplot.default <- function(x, scale=FALSE, col=1, pch=19, lty=1, xlim=c(0.5, ncol(x)+0.5), ylim=range(x), vertical = TRUE, ordered=FALSE, ...) { x <- as.data.frame(x) if (scale) x <- apply(x, 2, function(x) (x - min(x, na.rm = TRUE))/(max(x, na.rm = TRUE) - min(x, na.rm = TRUE))) if (NCOL(x) < 2) stop("'x' must have at least 2 columns") nr <- nrow(x) if (length(col) < nr) col <- rep(col, nr)[1:nr] if (length(pch) < nr) pch <- rep(pch, nr)[1:nr] if (length(lty) < nr) lty <- rep(lty, nr)[1:nr] if (ordered) x <- x[,order(colnames(x))] y <- data.frame(values=array(unlist(x)), ind=factor(rep(1:ncol(x), each=nrow(x)), labels=colnames(x))) id <- match(colnames(x),levels(y$ind)) if (vertical) { with(y, stripchart(values ~ ind, pch=pch, ylim=ylim, xlim=xlim, vertical=vertical, col="white", ...)) lapply(1:ncol(x), function(i) points(cbind(rep(i,nr), x[,id[i]]), col=col, pch=pch)) lapply(1:nr, function(i) lines(cbind(id, as.matrix(x)[i,]), col=col[i], lty=lty[i])) } else { tmp <- xlim xlim <- ylim ylim <- tmp with(y, stripchart(values ~ ind, pch=pch, ylim=ylim, xlim=xlim, vertical=vertical, col="white", ...)) lapply(1:ncol(x), function(i) points(cbind(x[,id[i]], rep(i,nr)), col=col, pch=pch)) lapply(1:nr, function(i) lines(cbind(as.matrix(x)[i,], id), col=col[i], lty=lty[i])) } invisible(NULL) } plotrix/R/ladderplot.R0000755000176000001440000000010211471167072014463 0ustar ripleyusersladderplot <- function (x, ...) UseMethod("ladderplot") plotrix/R/labbePlot.R0000644000176000001440000000302011564672763014247 0ustar ripleyusers# labbePlot reads a list of comparison trial results between two conditions, # typically "placebo" and "intervention" for clinical trials, # and plots each result as a circle centered at the percentage of successes # for each condition, with radius proportional to the square root of the # number of observations (multiplied by "circle.mag" for very small or large # numbers of observations), with optional fill colors. labbePlot<-function(x,main="L'Abbe plot", xlab="Percent positive response with placebo", ylab="Percent positive response with treatment", labels=NULL,col=NA,circle.mag=0.5,add=FALSE,...) { if(is.list(x)) { if(!add) plot(0,xlim=c(0,100),ylim=c(0,100),main=main,xlab=xlab, ylab=ylab,type="n",...) for(trial in 1:length(x)) { if(is.matrix(x[[trial]])) { sum_treat<-sum(x[[trial]][1,]) sum_interv<-sum(x[[trial]][2,]) xpos<-100*x[[trial]][1,1]/sum_treat ypos<-100*x[[trial]][2,1]/sum_interv rad<-circle.mag*sqrt(sum_treat+sum_interv) } else { xpos<-x[[trial]][1] ypos<-x[[trial]][2] rad<-circle.mag*sqrt(x[[trial]][3]) } circle.col<-ifelse(is.list(col),col[[trial]],col) draw.circle(xpos,ypos,rad,col=circle.col) if(!is.null(labels[[trial]])) { textcol<-ifelse(colSums(col2rgb(circle.col)*c(1,1.4,0.6)) < 350, "white", "black") text(xpos,ypos,labels[[trial]],col=textcol) } } segments(0,0,100,100) } else { cat("labbePlot: x must be a list of 2x2 tables OR\n") cat("3 element numeric vectors of percent, percent, N (see help page)\n") } } plotrix/R/kiteChart.R0000755000176000001440000000507112112011071014235 0ustar ripleyuserskiteChart<-function(x,xlim=NA,ylim=NA,timex=TRUE,main="Kite chart", xlab=ifelse(timex,"Time","Groups"),ylab=ifelse(timex,"Groups","Time"), border=par("fg"),col=NULL,varpos=NA,varlabels=NA,varscale=FALSE, timepos=NA,timelabels=NA,mar=c(5,4,4,4),axlab=c(1,2,3,4), normalize=is.na(varpos[1]),shownorm=TRUE,...) { # leave a bit more space on top if there is an axis if(varscale) mar<-mar+c(0,0,1,0) dimx<-dim(x) if(is.na(varpos[1])) varpos<-1:dimx[2] if(normalize) { kitewidths<-rep(1,dimx[2]) kitemax<-1 } else { if(is.na(varpos[1])) { kitewidths<-apply(as.matrix(x),1,max,na.rm=TRUE) varpos<-rep(0,length(kitewidths)-1) varpos[1]<-1.1*kitewidths[1]/2 for(kite in 2:length(kitewidths)) varpos[kite]<-varpos[kite-1]+1.1*(kitewidths[kite-1]+kitewidths[kite])/2 kitemax<-1.1*sum(kitewidths) } else { kitemax<-max(diff(varpos)) kitewidths<-apply(as.matrix(x),1,max,na.rm=TRUE) } } oldmar<-par(mar=mar) if(is.na(xlim[1])) { if(timex) xlim<-c(1,dimx[2]) else { if(normalize) xlim<-c(0.5,dimx[1]+0.5) else xlim<-c(0,kitemax) } } if(is.na(ylim[1])) { if(timex) { if(normalize) ylim<-c(0.5,dimx[1]+0.5) else ylim<-c(0,kitemax) } else ylim<-c(1,dimx[2]) } plot(0,xlim=xlim,ylim=ylim,main=main,xlab=xlab,ylab=ylab,type="n", axes=FALSE,...) if(is.na(varpos[1])) varpos<-1:dimx[1] if(is.na(varlabels[1])) { if(is.null(rownames(x))) varlabels<-varpos[1:dimx[1]] else varlabels<-rownames(x) } axis(ifelse(timex,axlab[2],axlab[1]),at=varpos[1:dimx[1]],labels=varlabels) if(is.na(timepos[1])) timepos<-1:dimx[2] if(is.na(timelabels[1])) { if(is.null(colnames(x))) timelabels<-timepos else timelabels<-colnames(x) } axis(ifelse(timex,axlab[1],axlab[2]),at=timepos,labels=timelabels) if(varscale && !normalize) { plotlim<-par("usr") mtext(round(kitewidths,1),side=3+timex,at=varpos) axis(3+timex,at=c(varpos-kitewidths/2,varpos+kitewidths/2), labels=rep("",2*length(varpos))) } box() if(is.null(col)) col<-rainbow(dimx[1]) if(length(col) < dimx[1]) col<-rep(col,length.out=dimx[1]) for(krow in 1:dimx[1]) { if(normalize) { if(shownorm) mtext(paste("*",signif(1/max(x[krow,]),digits=3)), ifelse(timex,axlab[4],axlab[3]),at=varpos[krow],las=1) x[krow,]<-x[krow,]/(max(x[krow,])) } xpos<-1:length(x[krow,]) if(timex) polygon(c(xpos,rev(xpos)), c(varpos[krow]+x[krow,]/2, varpos[krow]-rev(x[krow,])/2), col=col[krow],border=border) else polygon(c(varpos[krow]+x[krow,]/2, varpos[krow]-rev(x[krow,])/2), c(xpos,rev(xpos)), col=col[krow],border=border) } invisible(oldmar) } plotrix/R/intersectDiagram.R0000644000176000001440000001304111654223100015605 0ustar ripleyusersintersectDiagram<-function(x,pct=FALSE,show.nulls=FALSE,xnames=NULL, sep="+",mar=c(0,0,3,0),main="Intersection Diagram",cex=1,col=NULL, minspacing=NA,all.intersections=FALSE,include=NULL) { matchParts<-function(x,table,ignore.case=TRUE) { for(pattern in 1:length(x)) { match_index<-grep(x[pattern],table,ignore.case=ignore.case) if(length(match_index)) return(match_index) } return(0) } if(!match(class(x),"intersectList",0)) { if(is.matrix(x) || is.data.frame(x)) { if(is.data.frame(x)) x<-as.matrix(x) x<-makeIntersectList(x,xnames=xnames,sep=sep) } if(!match(class(x),"intersectList",0)) stop("x must be a matrix, data frame or intersectList") } oldmar<-par("mar") par(mar=mar) # attribute labels attributes<-x[[length(x)]] # get all the names for the individual attributes if(is.null(include)) include<-attributes # total number of attributes nattributes<-length(attributes) # peel off the number of objects and the attributes for display x[[length(x)]]<-NULL nobjects<-x[[length(x)]] x[[length(x)]]<-NULL # number of intersection levels with at least one object nlevels<-length(x) # if no colors specified, use rainbow if(is.null(col)) col<-c(rainbow(nattributes),NA) else if(length(col) < nattributes) col<-rep(col,length.out=nattributes) # total number of objects for each intersection level objectsums<-sapply(x,sum) # index of level with the most objects maxlevel<-which.max(objectsums) nNonZero<-function(x) return(sum(x > 0)) # number of intersections with at least one member for each intersection level # or all intersections if the somewhat dangerous "show everything" option is TRUE if(all.intersections) nintersects<-sapply(x,length) else nintersects<-sapply(x,nNonZero) # maximum number of intersections in a given level maxintersections<-max(nintersects) # largest intersection set in x maxn<-max(unlist(x)) # default to a minimum spacing of one tenth of the largest intersection set if(is.na(minspacing)) minspacing<-0.1 * maxn # x limit that will hold the maximum number of objects and allow # spacing for the maximum number of intersections in units of objects maxx<-objectsums[maxlevel] + minspacing * maxintersections # have to escape the separator in case it is "+" (default) or # some other character that means something to some function attsep<-paste("[",sep,"]",sep="") # display the empty plot plot(0,xlim=c(0,maxx),ylim=c(0,nlevels+show.nulls), main=main,xlab="",ylab="",type="n",axes=FALSE) # step through each level of intersections for(level in 1:nlevels) { # determine the intersect level by the number of elements in the first name intersectLevel<-length(unlist(strsplit(names(x[[level]][1]),attsep))) # indices of intersections with at least one object in this level # or just all of the intersections if(all.intersections) intersections<-1:nintersects[[level]] else intersections<-which(x[[level]] > 0) # get all the names in this level with at least one object blocknames<-names(x[[level]])[intersections] # spacing between intersection sets in object units spacing<-(maxx - objectsums[level])/nintersects[level] # left edges of the rectangles in x positions leftx<-c(0,cumsum(x[[level]][intersections] + spacing)) + spacing/2 # now step through the intersections in this level for(intersect in 1:length(intersections)) { # check if this intersection is to be displayed if(matchParts(include,blocknames[intersect])) { # make the label for the intersection cellqnt<-ifelse(pct, paste(round(100*x[[level]][intersections[intersect]]/nobjects,1),"%",sep=""), x[[level]][intersections[intersect]]) # indices of the colors to use for this rectangle colindex<- which(attributes %in% unlist(strsplit(blocknames[intersect],attsep))) # number of colors ncol<-length(colindex) # width of each color slice xinc<-x[[level]][intersections[intersect]]/ncol # colors for the slices slicecol<-col[colindex] # start at the left edge of the sliced rectangle offset<-0 # step through the slices for(slice in 1:ncol) { # first draw the rectangle with no border rect(leftx[intersect]+offset,nlevels-level+show.nulls+0.1, leftx[intersect]+offset+xinc,nlevels-level+show.nulls+0.9, col=slicecol[slice],border=NA) # move to the left edge of the next slice offset<-offset+xinc } # draw a box around the sliced rectangle rect(leftx[intersect],nlevels-level+show.nulls+0.1, leftx[intersect]+x[[level]][intersections[intersect]], nlevels-level+show.nulls+0.9) # display the label for this rectangle boxed.labels(leftx[intersect]+x[[level]][intersections[intersect]]/2, nlevels-level+show.nulls+0.5, paste(blocknames[intersect],cellqnt,sep="\n"),cex=cex) } } } if(show.nulls) { # number of objects with no set membership or no attributes nonset<-as.numeric(nobjects - sum(objectsums)) # left edge of the rectangle leftnulls<-sum(par("usr")[1:2])/2-nonset/2 # draw the rectangle if(nonset) rect(leftnulls,0.1,leftnulls+nonset,0.9) # center of the rectangle xpos<-leftnulls+nonset/2 # display the label if(pct) nonset<-paste(round(100*nonset/nobjects,1),"%",sep="") boxed.labels(xpos,0.5,paste("Non-members",nonset,sep="\n"),cex=cex) } # restore the original plot parameters par(mar=oldmar) # stick the number of objects and attributes back on x[[length(x) + 1]]<-nobjects x[[length(x) + 1]]<-attributes invisible(x) } plotrix/R/gradient.rect.R0000755000176000001440000000237411056465626015104 0ustar ripleyusersgradient.rect<-function(xleft,ybottom,xright,ytop,reds,greens,blues, col=NULL,nslices=50,gradient="x",border=par("fg")) { if(is.null(col)) col<-color.gradient(reds, greens, blues, nslices) else nslices<-length(col) nrect<-max(unlist(lapply(list(xleft,ybottom,xright,ytop),length))) if(nrect > 1) { if(length(xleft) < nrect) xleft<-rep(xleft,length.out=nrect) if(length(ybottom) < nrect) ybottom<-rep(ybottom,length.out=nrect) if(length(xright) < nrect) xright<-rep(xright,length.out=nrect) if(length(ytop) < nrect) ytop<-rep(ytop,length.out=nrect) for(i in 1:nrect) gradient.rect(xleft[i],ybottom[i],xright[i],ytop[i], reds,greens,blues,col,nslices,gradient,border=border) } else { if (gradient == "x") { xinc <- (xright - xleft)/nslices xlefts <- seq(xleft, xright - xinc, length = nslices) xrights <- xlefts + xinc rect(xlefts,ybottom,xrights,ytop,col=col,lty=0) rect(xlefts[1],ybottom,xrights[nslices],ytop,border=border) } else { yinc <- (ytop - ybottom)/nslices ybottoms <- seq(ybottom, ytop - yinc, length = nslices) ytops <- ybottoms + yinc rect(xleft,ybottoms,xright,ytops,col=col,lty=0) rect(xleft,ybottoms[1],xright,ytops[nslices],border=border) } } invisible(col) } plotrix/R/getMarginWidth.R0000755000176000001440000000163411302733244015252 0ustar ripleyusersgetMarginWidth<-function(side=4,labels,is.legend=FALSE) { currentmar<-par("mar") currentpin<-par("pin")[1] currentfin<-par("fin")[1] currentusr<-par("usr") if(is.legend) marwidth<-1.2*legend(0,0,labels,fill=NA,plot=FALSE)$rect$w else marwidth<-1.1*max(strwidth(labels)) marprop<-ifelse(side==2,currentmar[2]/(currentmar[2]+currentmar[4]), currentmar[4]/(currentmar[2]+currentmar[4]))*(currentfin-currentpin)/currentfin plotprop<-currentpin/currentfin plotwidth<-currentusr[2]-currentusr[1] marusr<-(marprop/plotprop)*plotwidth newmar<-ifelse(side==2,currentmar[2],currentmar[4])*marwidth/marusr cat("plotprop",plotprop,"marprop",marprop,"plotwidth", plotwidth,"marwidth",marwidth,"\n") marcenter<-currentusr[2]+marwidth/2 if(marwidth>plotwidth) { warning("figure size too small for new margin!") newmar<-ifelse(side==2,currentmar[2],currentmar[4]) } return(list(newmar=newmar,marcenter=marcenter)) } plotrix/R/getIntersectList.R0000755000176000001440000000200411644507132015625 0ustar ripleyusersgetIntersectList<-function(nelem,xnames=NULL,sep="+") { if(is.null(xnames)) xnames<-LETTERS[1:nelem] xnamelen<-length(xnames) if(xnamelen < nelem) { extranames<-paste("extra",1:(nelem-xnamelen),sep=sep) cat("Not enough names in",xnames,"adding",extranames,"\n") xnames<-c(xnames,extranames) } intersectList<-vector("list",nelem+2) total_n<-0 for(comb in 1:nelem) { nn<-choose(nelem,comb) intersectList[[comb]]<-rep(0,nn) currentnames<-names(intersectList[[comb]])<- pasteCols(combn(xnames,comb),sep=sep) for(intersect in 1:nn) { cat("Number of elements in",currentnames[intersect],"- ") current_n<-scan(nmax=1,quiet=TRUE) intersectList[[comb]][intersect]<-current_n total_n<-total_n+current_n } } cat("Total number of elements (press Enter for ",total_n,") - ", sep="") intersectList[[nelem + 1]]<-scan(nmax=1,quiet=TRUE) if(length(intersectList[[nelem+1]])==0) intersectList[[nelem+1]]<-total_n intersectList[[nelem+2]]<-xnames class(intersectList) <- "intersectList" return(intersectList) } plotrix/R/getFigCtr.R0000755000176000001440000000066311411623542014214 0ustar ripleyusersgetFigCtr<-function(pos=c(0.5,0.5)) { pars<-par(c("usr","mar","fin","pin")) pxspan<-diff(pars$usr[1:2]) fxspan<-pxspan*pars$fin[1]/pars$pin[1] figxctr<- pars$usr[1]-(fxspan-pxspan)*pars$mar[2]/(pars$mar[2]+pars$mar[4]) + fxspan*pos[1] pyspan<-diff(pars$usr[3:4]) fyspan<-pyspan*pars$fin[2]/pars$pin[2] figyctr<- pars$usr[1]-(fyspan-pyspan)*pars$mar[1]/(pars$mar[1]+pars$mar[3]) + fyspan*pos[2] return(c(figxctr,figyctr)) } plotrix/R/gap.plot.R0000755000176000001440000001324011361054624014060 0ustar ripleyusers# Try to rewrite this for an arbitrary number of gaps gap.plot<-function(x,y,gap,gap.axis="y",bgcol="white",breakcol="black", brw=0.02,xlim,ylim,xticlab,xtics=NA,yticlab,ytics=NA,lty=rep(1,length(x)), col=rep(par("col"),length(x)),pch=rep(1,length(x)),add=FALSE,...) { if(missing(y) && !missing(x)) { y<-x x<-1:length(y) } if(missing(gap)) stop("gap must be specified") gapsize<-diff(gap) xaxl<-par("xlog") yaxl<-par("ylog") if(missing(ylim)) { if(gap.axis == "y") { if(length(gap) > 3) ylim<-c(min(y),max(y) - (gapsize[1] + gapsize[3])) else ylim<-c(min(y),max(y)-gapsize[1]) if(missing(xlim)) xlim<-range(x) } } if(missing(xlim)) { if(gap.axis == "x") { if(length(gap) > 3) xlim<-c(min(x),max(x) - (gapsize[1] + gapsize[3])) else xlim<-c(min(x),max(x)-gapsize[1]) if(missing(ylim)) ylim<-range(y) } } rangexy <- c(range(xlim),range(ylim)) xgw<-(rangexy[2]-rangexy[1])*brw ygw<-(rangexy[4]-rangexy[3])*brw if(is.na(xtics[1])) xtics<-pretty(x) if(is.na(ytics[1])) ytics<-pretty(y) if(missing(xticlab)) xticlab<-xtics if(missing(yticlab)) yticlab<-ytics if(length(col) < length(y)) col<-rep(col,length.out=length(y)) if(gap.axis == "y") { littleones<-which(y < gap[1]) if(length(gap) > 3) { middleones<-which(y >= gap[2] + ygw & y < gap[3]) bigones<-which(y >= gap[4] + ygw) lostones<-sum(c(y > gap[1] & y < gap[2] + ygw,y > gap[3] & y < gap[4] + ygw)) } else { middleones<-NA bigones<-which(y >= gap[2] + ygw) lostones<-sum(y > gap[1] & y < gap[2] + ygw) } if(lostones) warning("some values of y will not be displayed") } else { littleones<-which(x < gap[1]) if(length(gap) > 3) { middleones<-which(x >= gap[2] + xgw & x < gap[3]) bigones<-which(x >= gap[4] + xgw) lostones<-sum(c(x > gap[1] & x < gap[2] + xgw,x > gap[3] & x < gap[4] + xgw)) if(missing(xlim)) xlim<-c(min(x),max(x) - (gapsize[1] + gapsize[3])) } else { middleones<-NA bigones<-which(x >= gap[2]) lostones<-sum(x > gap[1] & x < gap[2] + xgw) if(missing(xlim)) xlim<-c(min(x),max(x) - gapsize[1]) } if(lostones) warning("some values of x will not be displayed") if(missing(ylim)) ylim<-range(y) } if(length(lty) < length(x)) lty<-rep(lty,length.out=length(x)) if(length(col) < length(x)) col<-rep(col,length.out=length(x)) if(length(pch) < length(x)) pch<-rep(pch,length.out=length(x)) if(add) { points(x[littleones],y[littleones],lty=lty[littleones], col=col[littleones],pch=pch[littleones],...) if(gap.axis == "y") { if(length(gapsize) > 2) { points(x[middleones],y[middleones]-gapsize[1], lty=lty[middleones],col=col[middleones],pch=pch[middleones],...) points(x[bigones],y[bigones] - (gapsize[1] + gapsize[3]), lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } else points(x[bigones],y[bigones]-gapsize[1], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } else { if(length(gapsize) > 2) { points(x[middleones] - gapsize[1],y[middleones], lty=lty[middleones],col=col[middleones],pch=pch[middleones],...) points(x[bigones] - (gapsize[1] + gapsize[3]),y[bigones], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } else points(x[bigones]-gapsize[1],y[bigones], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } } else { plot(x[littleones],y[littleones],xlim=xlim,ylim=ylim,axes=FALSE, lty=lty[littleones],col=col[littleones],pch=pch[littleones],...) box() if(gap.axis == "y") { if(!is.na(xtics[1])) axis(1,at=xtics,labels=xticlab) littletics<-which(ytics < gap[1]) if(length(gapsize) > 2) { middletics<-which(ytics >= gap[2] & ytics <= gap[3]) bigtics<-which(ytics >= gap[4]) show.at<-c(ytics[littletics],ytics[middletics] - gapsize[1], ytics[bigtics]-(gapsize[1] + gapsize[3])) show.labels<-c(yticlab[littletics],yticlab[middletics],yticlab[bigtics]) } else { bigtics<-which(ytics >= gap[2]) show.at<-c(ytics[littletics],ytics[bigtics] - gapsize[1]) show.labels<-c(ytics[littletics],yticlab[bigtics]) } axis(2,at=show.at,labels=show.labels) axis.break(2,gap[1],style="gap",bgcol=bgcol, breakcol=breakcol,brw=brw) if(length(gapsize) > 2) { axis.break(2,gap[3]-gapsize[1],style="gap",bgcol=bgcol, breakcol=breakcol,brw=brw) points(x[middleones],y[middleones]-gapsize[1], lty=lty[middleones],col=col[middleones],pch=pch[middleones],...) points(x[bigones],y[bigones]-(gapsize[1]+gapsize[3]), lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } else points(x[bigones],y[bigones]-gapsize[1], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } # x gaps need to be fixed else { if(!is.na(ytics[1])) axis(2,at=ytics,labels=yticlab) littletics<-which(xtics 2) { middletics<-which(xtics >= gap[2] & xtics <= gap[3]) bigtics<-which(xtics >= gap[4]) show.at<-c(xtics[littletics],xtics[middletics]-gapsize[1], xtics[bigtics]-(gapsize[1]+gapsize[3])) show.labels<-c(xticlab[littletics],xticlab[middletics],xticlab[bigtics]) } else { bigtics<-which(xtics >= gap[2]) show.at<-c(xtics[littletics],xtics[bigtics]-gapsize[1]) show.labels<-c(xticlab[littletics],xticlab[bigtics]) } axis(1,at=show.at,labels=show.labels) axis.break(1,gap[1],style="gap") if(length(gapsize) > 2) { axis.break(1,gap[3]-gapsize[1],style="gap") points(x[middleones]-gapsize[1],y[middleones], lty=lty[middleones],col=col[middleones],pch=pch[middleones],...) points(x[bigones]-(gapsize[1]+gapsize[3]),y[bigones], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } else points(x[bigones]-gapsize[1],y[bigones], lty=lty[bigones],col=col[bigones],pch=pch[bigones],...) } } } plotrix/R/gap.boxplot.R0000755000176000001440000001001011573135531014563 0ustar ripleyusersgap.boxplot<-function (x,...,gap=list(top=c(NA,NA),bottom=c(NA,NA)), range=1.5,width=NULL,varwidth=FALSE,notch=FALSE,outline=TRUE,names, ylim=NA,plot=TRUE,border=par("fg"),col=NULL,log="",axis.labels=NULL, pars=list(boxwex=0.8,staplewex=0.5,outwex=0.5), horizontal=FALSE,add=FALSE,at=NULL,main=NULL) { if(!is.na(gap$top[1])) if(gap$top[1] > gap$top[2]) gap$top<-rev(gap$top) if(!is.na(gap$bottom[1])) if(gap$bottom[1] > gap$bottom[2]) gap$bottom<-rev(gap$bottom) if(is.na(ylim[1])) { bxpt<-boxplot(x,...,range=range,plot=FALSE) ylim<-range(c(bxpt$stats,bxpt$out)) } else bxpt<-boxplot(x,...,ylim=ylim,range=range,plot=FALSE) bxgap<-bxpt if(!is.na(gap$top[1])) { bxgap$stats[bxgap$stats > gap$top[1] & bxgap$stats < gap$top[2]]<-NA if(any(is.na(bxgap$stats))) stop("gap cannot include the median, interquartiles or the staples") topdiff<-diff(gap$top) bxgap$stats[bxgap$stats > gap$top[2]]<- bxgap$stats[bxgap$stats > gap$top[2]]-topdiff intopgap<-bxgap$out > gap$top[1] & bxgap$out < gap$top[2] bxgap$out[intopgap]<-NA abovetop<-which(bxgap$out > gap$top[2]) bxgap$out[abovetop]<-bxgap$out[abovetop]-topdiff rangetop<-gap$top[1] ylim[2]<-ylim[2]-topdiff } else rangetop<-ylim[2] if(!is.na(gap$bottom[1])) { bxgap$stats[bxgap$stats > gap$bottom[1] & bxgap$stats < gap$bottom[2]] <- NA if(any(is.na(bxgap$stats))) stop("gap cannot include the median, interquartiles or the staples") bottomdiff<-diff(gap$bottom) bxgap$stats[bxgap$stats < gap$bottom[1]]<- bxgap$stats[bxgap$stats < gap$bottom[1]]+bottomdiff bxgap$out[bxgap$out > gap$bottom[1] & bxgap$out < gap$bottom[2]] <- NA belowbottom<-which(bxgap$out < gap$bottom[1]) bxgap$out[belowbottom]<-bxgap$out[belowbottom]+bottomdiff rangebottom<-gap$bottom[2] ylim[1]<-ylim[1]+bottomdiff } else rangebottom<-ylim[1] if(any(is.na(bxgap$out))) warning("At least one outlier falls into a gap") nboxes<-dim(bxgap$stats)[2] plot(0,xlim=c(0.5,nboxes+0.5),ylim=ylim,type="n", axes=FALSE,xlab="",ylab="",main=main) plotlim<-par("usr") box() axis(1,labels=bxpt$names,at=1:nboxes) midticks<-pretty(c(rangebottom,rangetop)) axis(2,at=midticks[midticks > rangebottom & midticks < rangetop]) if(is.null(width)) width<-pars$boxwex rect(1:nboxes-width/2,bxgap$stats[2,],1:nboxes+width/2, bxgap$stats[4,],border=border,col=col) if(notch) { ymult<-diff(plotlim[3:4])/diff(plotlim[1:2]) if(is.null(col)) boxcol<-"white" else boxcol<-col rect(1:nboxes-width/1.95,bxgap$conf[1,],1:nboxes+width/1.95, bxgap$conf[2,],border=NA,col=boxcol) median.left<-1:nboxes+width*bxgap$conf[1]/(ymult*nboxes)-width/2 median.right<-1:nboxes-width*bxgap$conf[1]/(ymult*nboxes)+width/2 segments(1:nboxes-width/2,bxgap$conf[1,],median.left, bxgap$stats[3,],col=border) segments(1:nboxes-width/2,bxgap$conf[2,],median.left, bxgap$stats[3,],col=border) segments(median.right,bxgap$stats[3,],1:nboxes+width/2, bxgap$conf[1,],col=border) segments(median.right,bxgap$stats[3,],1:nboxes+width/2, bxgap$conf[2,],col=border) } else { median.left<-1:nboxes-width/2 median.right<-1:nboxes+width/2 } segments(median.left,bxgap$stats[3,],median.right,bxgap$stats[3,], lwd=2,col=border) segments(1:nboxes,bxgap$stats[1,],1:nboxes,bxgap$stats[2,], lty=2,col=border) segments(1:nboxes, bxgap$stats[4,],1:nboxes,bxgap$stats[5,], lty=2,col=border) segments(1:nboxes-pars$staplewex*width/2,bxgap$stats[1,], 1:nboxes+pars$staplewex*width/2,bxgap$stats[1,],col = border) segments(1:nboxes-pars$staplewex*width/2,bxgap$stats[5,], 1:nboxes+pars$staplewex*width/2,bxgap$stats[5,],col=border) if(!is.na(gap$top[1])) topadjust<-diff(gap$top) else topadjust<-0 if(!is.na(gap$bottom[1])) bottomadjust<-diff(gap$bottom) else bottomadjust<-0 if(!is.null(axis.labels)) axis(2,labels=axis.labels, at=c(axis.labels[1]+bottomadjust,axis.labels[2]-topadjust)) if(!is.na(gap$top[1])) axis.break(2,gap$top[1],style="gap") if(!is.na(gap$bottom[1])) axis.break(2,gap$bottom[2]-diff(plotlim[3:4])*0.02,style="gap") points(bxgap$group,bxgap$out) invisible(bxgap) } plotrix/R/gap.barplot.R0000755000176000001440000000431611517775073014564 0ustar ripleyusersgap.barplot<-function (y,gap,xaxlab,xtics,yaxlab,ytics,xlim=NA,ylim=NA, xlab=NULL,ylab=NULL,horiz=FALSE,col=NULL,...) { if (missing(y)) stop("y values required") if(missing(xtics)) xtics <- 1:length(y) if (missing(gap)) stop("gap must be specified") if (is.null(ylab)) ylab <- deparse(substitute(y)) if (is.null(col)) col <- color.gradient(c(0,1),c(0,1,0),c(1,0),length(y)) else if(length(col) < length(y)) rep(col,length.out=length(y)) littleones <- which(y <= gap[1]) bigones <- which(y >= gap[2]) valid.y<-y[!is.na(y)] if(any(valid.y > gap[1] & valid.y < gap[2])) warning("gap includes some values of y") gapsize <- gap[2] - gap[1] if(missing(xaxlab)) xaxlab <- as.character(xtics) if(is.na(xlim[1])) xlim <- range(xtics) if(is.na(ylim[1])) ylim <- c(min(valid.y),max(valid.y) - gapsize) if(missing(ytics)) ytics <- pretty(y) if(missing(yaxlab)) yaxlab <- ytics littletics <- which(ytics < gap[1]) bigtics <- which(ytics >= gap[2]) halfwidth <- min(diff(xtics))/2 if(horiz) { if(!is.null(xlab)) { tmplab<-xlab xlab<-ylab ylab<-tmplab } plot(0,xlim=ylim,ylim=xlim,xlab=xlab,ylab=ylab,axes=FALSE,type="n",...) plot.lim <- par("usr") botgap<-ifelse(gap[1]<0,gap[1],ylim[1]) box() axis(2,at=xtics,labels=xaxlab,...) axis(1,at=c(ytics[littletics],ytics[bigtics]-gapsize), labels=c(ytics[littletics],ytics[bigtics]),...) rect(botgap,xtics[y 10) { nextpriority <- as.numeric(readline("Task priority (1-10) - ")) if(is.na(nextpriority)) { cat("Task priority must be a number between 1 and 10!\n") next.priority<-0 } } if(is.na(priorities[1])) priorities<-nextpriority else priorities<-c(priorities,nextpriority) } } return(list(labels=tasklabels,starts=taskstarts,ends=taskends, priorities=priorities)) } gantt.chart<-function(x=NULL,format="%Y/%m/%d",xlim=NULL,taskcolors=NULL, priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format="%Y/%m/%d", half.height=0.25,hgrid=FALSE,main="",xlab="",cylindrical=FALSE,label.cex=1, border.col=NA,priority.label="Priorities",priority.extremes=c("High","Low")) { oldpar<-par("mai","omi","xpd","xaxs","yaxs") if(is.null(x)) x<-get.gantt.info(format=format) if(any(x$starts > x$ends)) stop("Can't have a start date after an end date") tasks<-unique(x$labels) ntasks<-length(tasks) if(is.null(x$priorities)) x$priorities <- rep(1, ntasks) if(is.null(dev.list())) plot.new() charheight<-strheight("M",units="inches") oldcex<-par(cex=label.cex) maxwidth<-max(strwidth(x$labels,units="inches")) + 0.3 par(oldcex) if(is.null(xlim)) xlim = range(c(x$starts, x$ends)) npriorities<-max(x$priorities) if(is.null(taskcolors)) taskcolors<-barcolors<-rainbow(npriorities) else barcolors<-taskcolors if(length(barcolors) < ntasks) barcolors <- barcolors[x$priorities] nlabels<-length(x$labels) if(length(barcolors) < nlabels) barcolors<-barcolors[as.numeric(factor(x$labels))] bottom.margin<-ifelse(priority.legend || nchar(xlab),0.7,0) par(mai=c(bottom.margin,maxwidth,charheight*5,0.1)) par(omi=c(0.1,0.1,0.1,0.1),xaxs="i",yaxs="i") plot(range(x$starts),c(1,ntasks),xlim=xlim,ylim=c(0.5,ntasks+0.5), main="",xlab="",ylab="",axes=FALSE,type="n") box() if(nchar(main)) mtext(main,3,2,at=getFigCtr()[1]) if(nchar(xlab)) mtext(xlab,1,1) if(is.na(vgrid.format)) { if(is.null(vgridlab)) vgridlab<-vgridpos axis(3,at=vgridpos,labels=vgridlab) tickpos<-vgridpos } else { if(is.null(vgridpos)) tickpos<-axis.POSIXct(3,xlim,format=vgrid.format) else tickpos<-vgridpos if(is.null(vgridlab) && !is.null(vgridpos)) vgridlab<-format.POSIXct(vgridpos,vgrid.format) if(is.null(vgridlab)) axis.POSIXct(3,xlim,format=vgrid.format) else axis(3,at=tickpos,labels=vgridlab) } topdown<-seq(ntasks,1) axis(2,at=topdown,labels=tasks,las=2,cex.axis=label.cex) abline(v=tickpos,col="darkgray",lty=3) for(i in 1:ntasks) { if(cylindrical) cylindrect(x$starts[x$labels == tasks[i]],topdown[i]-half.height, x$ends[x$labels == tasks[i]],topdown[i]+half.height,col=barcolors[i], gradient="y") else rect(x$starts[x$labels == tasks[i]],topdown[i]-half.height, x$ends[x$labels == tasks[i]],topdown[i]+half.height, col=barcolors[x$labels == tasks[i]],border=border.col) } if(hgrid) abline(h=(topdown[1:(ntasks-1)]+topdown[2:ntasks])/2,col="darkgray",lty=3) if(priority.legend) { par(xpd=TRUE) plim<-par("usr") gradient.rect(plim[1],plim[3]-(plim[4]-plim[3])/10, plim[1]+(plim[2]-plim[1])/4,plim[3]-(plim[4]-plim[3])/20,col=taskcolors) par(xpd=NA) text(plim[1]+(plim[2]-plim[1])/8,plim[3]-(plim[4]-plim[3])/9, priority.label,adj=c(0.5,1)) par(xpd=FALSE) mtext(priority.extremes,side=1,line=0, at=c(plim[1],plim[1]+(plim[2]-plim[1])/4),cex=0.8) } par(oldpar) invisible(x) } plotrix/R/fullaxis.R0000755000176000001440000000135111171075620014161 0ustar ripleyusersfullaxis<-function(side=1,at=NULL,labels=TRUE,line=NA,pos=NA,outer=FALSE, font=NA,lty="solid",lwd=1,lwd.ticks=lwd,col=NULL,col.ticks=NULL, hadj=NA,padj=NA,...) { xylim<-par("usr") if(!is.na(pos)) xylim[c(3,1,4,2)[side]]<-pos par(xpd=TRUE) switch(side, segments(xylim[1],xylim[3],xylim[2],xylim[3],col=col,lty=lty,lwd=lwd), segments(xylim[1],xylim[3],xylim[1],xylim[4],col=col,lty=lty,lwd=lwd), segments(xylim[1],xylim[4],xylim[2],xylim[4],col=col,lty=lty,lwd=lwd), segments(xylim[2],xylim[3],xylim[2],xylim[4],col=col,lty=lty,lwd=lwd)) par(xpd=FALSE) axpos<-axis(side=side,at=at,labels=labels,line=line,pos=pos,outer=outer, font=font,lty=lty,lwd=lwd,col=col,col.ticks=col.ticks, hadj=hadj,padj=padj,...) invisible(axpos) } plotrix/R/floatpie.R0000755000176000001440000000336412112314562014140 0ustar ripleyusers# display a pie chart at an arbitrary location on an existing plot floating.pie<-function(xpos,ypos,x,edges=200,radius=1,col=NULL, startpos=0,shadow=FALSE,shadow.col=c("#ffffff","#cccccc"),...) { if (!is.numeric(x) || any(is.na(x) | x<=0)) stop("floating.pie: x values must be positive.") x<-c(0,cumsum(x)/sum(x)) dx <- diff(x) nx <- length(dx) if (is.null(col)) col<-rainbow(nx) else if(length(col) < nx) col<-rep(col,nx) # scale the y radius xylim<-par("usr") plotdim<-par("pin") yradius<-radius*(xylim[4]-xylim[3])/(xylim[2]-xylim[1])*plotdim[1]/plotdim[2] # get the center values in radians bc<-2*pi*(x[1:nx]+dx/2)+startpos if(shadow) { xc<-c(cos(seq(0,2*pi,length=edges))*radius+xpos) yc<-c(sin(seq(0,2*pi,length=edges))*yradius+ypos) polygon.shadow(xc,yc,col=shadow.col) } for(i in 1:nx) { n<-max(2,floor(edges*dx[i])) t2p<-2*pi*seq(x[i],x[i + 1],length=n)+startpos xc<-c(cos(t2p)*radius+xpos,xpos) yc<-c(sin(t2p)*yradius+ypos,ypos) polygon(xc,yc,col=col[i],...) t2p<-2*pi*mean(x[i+0:1])+startpos xc<-cos(t2p)*radius yc<-sin(t2p)*radius } invisible(bc) } # place text labels at the specified distance from x,y on the radial lines # specified by angles. pie.labels<-function(x,y,angles,labels,radius=1,bg="white",border=TRUE, minangle=NA,...) { if(nargs()<4) stop("Usage: pie.labels(x,y,angles,labels,radius=1,bg=\"white\",border=TRUE,...)") # turn off clipping par(xpd=TRUE) # scale the y radius xylim<-par("usr") plotdim<-par("pin") yradius<-radius*(xylim[4]-xylim[3])/(xylim[2]-xylim[1])*plotdim[1]/plotdim[2] if(!is.na(minangle)) angles<-spreadout(angles,minangle) xc<-cos(angles)*radius+x yc<-sin(angles)*yradius+y boxed.labels(xc,yc,labels,bg=bg,border=border,...) # turn clipping back on par(xpd=FALSE) } plotrix/R/feather.plot.R0000755000176000001440000000142011755413707014734 0ustar ripleyusersfeather.plot<-function(r,theta,xpos,yref=0,use.arrows=TRUE, col.refline="lightgray",fp.type="s",main="",xlab="",ylab="", xlabels=NULL,...) { if(missing(xpos)) xpos<-1:length(theta) # reverse the angles and start at 12 o'clock if(fp.type == "m") theta<-5*pi/2-theta x<-r*cos(theta) y<-r*sin(theta) xmult<-diff(range(xpos))/(diff(range(y))*2) x<-x*xmult xlim<-range(c(xpos,x+xpos)) ylim<-range(c(y,yref)) oldpin<-par("pin") xdiff<-xlim[2]-xlim[1] ydiff<-ylim[2]-ylim[1] plot(0,xlim=xlim,ylim=ylim,type="n",main=main,xlab=xlab,ylab=ylab,axes=FALSE) box() if(is.null(xlabels)) axis(1) else axis(1,at=xpos,labels=xlabels) abline(h=yref,col=col.refline) if(use.arrows) arrows(xpos,yref,xpos+x,y,length=0.1,...) else segments(xpos,yref,xpos+x,y,...) par(pin=oldpin) } plotrix/R/fan.plot.R0000755000176000001440000000771411056465626014077 0ustar ripleyusersfan.plot<-function (x,edges=200,radius=1,col=NULL,align.at=NULL, max.span=NULL,labels=NULL,labelpos=NULL,label.radius=1.2,align="left", shrink=0.02,main="",ticks=NULL,include.sumx=FALSE,...) { if(!is.numeric(x) || any(is.na(x) | x <= 0)) stop("fan.plot: x values must be positive.") nticks<-ifelse(ticks==1,sum(x),ticks) if(include.sumx) x<-c(x,sum(x)) xorder<-order(x, decreasing = TRUE) oldmar<-par("mar") # convert values into angular extents if (align == "center") x<-pi*x/sum(x) else x<-2*pi*x/sum(x) # stretch or shrink the values if max.span has been specified if(!is.null(max.span)) x<-x*max.span/max(x) if(is.null(align.at)) { if(align == "center") align.at<-pi/2 if(align == "right") align.at<-(pi - x[xorder[1]])/2 if(align == "left") align.at<-(pi + x[xorder[1]])/2 } nx<-length(x) tempradius<-radius if(is.null(col)) col<-rainbow(nx) else if (length(col) < nx) col<-rep(col,length = nx) if(align == "left") lowpoint<-min(sin(align.at-x)) else lowpoint<-min(sin(align.at+x)) if(lowpoint > 0) lowpoint<-0 par(mar=c(1,1,1,1),xpd=TRUE) xspan<-max(label.radius+0.012*max(nchar(labels))) plot(0,xlim=c(-xspan,xspan),ylim=c(lowpoint,xspan), xlab="",ylab="",type="n",axes=FALSE) xy<-par("usr") pinxy<-par("pin") ymult<-(xy[4]-xy[3])/(xy[2]-xy[1])*(pinxy[1]/pinxy[2]) if(nchar(main)) text(0,(max(label.radius)+0.2)*ymult,main,cex=1.5,adj=c(0.5,1)) for(i in 1:nx) { n<-edges*x[xorder[i]]/pi if(align == "center") t2p<-seq(align.at-x[xorder[i]],align.at+x[xorder[i]],length=n) if (align == "right") t2p<-seq(align.at,align.at+x[xorder[i]],length=n) if(align=="left") t2p<-seq(align.at-x[xorder[i]],align.at,length=n) xc<-c(cos(t2p)*tempradius,0) yc<-c(sin(t2p)*tempradius*ymult,0) polygon(xc,yc,col=col[xorder[i]],...) tempradius<-tempradius-shrink } if(!is.null(ticks)) { if(align == "left") tickles<-seq(align.at,align.at-x[xorder[1]],by=-sum(x)/ticks) if(align == "right") tickles<-seq(align.at,align.at+x[xorder[1]],by=sum(x)/ticks) if(align == "center") tickles<-c(seq(align.at,align.at+x[xorder[1]],by=sum(x)/(2*ticks)), seq(align.at,align.at-x[xorder[1]],by=-sum(x)/(2*ticks))) stickout<-rep(c(0.04,rep(0.02,4),0.03,rep(0.02,4)), length.out=length(tickles)) xpos1<-cos(tickles) * (radius + stickout) ypos1<-sin(tickles) * ymult * (radius + stickout) xpos2<-cos(tickles) * radius ypos2<-sin(tickles) * ymult * radius segments(xpos1, ypos1, xpos2, ypos2) } if(!is.null(labels)) { par(xpd=TRUE) if(align == "center") { labelside<-rep(c(1, -1),length.out=nx-1) lpos<-c(align.at+labelside*(x[xorder[1:(nx-1)]]+ (x[xorder[2:nx]]-x[xorder[1:(nx-1)]])/2),align.at) } if(align == "right") { lpos<-align.at+(x[xorder]-c((x[xorder[1:(nx-1)]]- x[xorder[2:nx]])/2,x[xorder[nx]]/2)) labelside<-rep(1,nx) } if(align == "left") { lpos<-align.at-(x[xorder]-c((x[xorder[1:(nx-1)]]- x[xorder[2:nx]])/2,x[xorder[nx]]/2)) labelside<-rep(-1,nx) } if(is.null(labelpos)) { labelpos<-lpos ldiff<-abs(diff(labelpos)) squeezers<-which(ldiff<0.15) if(length(squeezers)) { for(squeeze in squeezers) { labelpos[1:squeeze]<-labelpos[1:squeeze]+ (0.15-ldiff[squeeze]) * labelside[1:squeeze] labelpos[(squeeze+1):nx]<-labelpos[(squeeze+1):nx]- (0.15-ldiff[squeeze]) * labelside[(squeeze+1):nx] } } } innerend<-seq(0.98,by=-shrink,length=nx) endpos<-lpos if(length(label.radius) < nx) label.radius<-rep(label.radius,length.out=nx) xpos1<-cos(labelpos)*label.radius[xorder] ypos1<-sin(labelpos)*ymult*label.radius[xorder] for(i in 1:nx) boxed.labels(xpos1[i],ypos1[i],labels[xorder[i]], border=FALSE,xpad=0,ypad=0.1,adj=c(0.5-cos(labelpos[i])/2.5,0.5)) xpos1<-cos(labelpos)*(label.radius[xorder]+radius)/2 ypos1<-sin(labelpos)*ymult*(label.radius[xorder]+radius)/2 xpos2<-cos(endpos)*radius*innerend ypos2<-sin(endpos)*ymult*radius*innerend segments(xpos1,ypos1,xpos2,ypos2) } par(mar=oldmar,xpd=FALSE) invisible(labelpos) } plotrix/R/emptyspace.R0000755000176000001440000000326611403647112014512 0ustar ripleyusersemptyspace<-function(x,y=NULL) { xlim<-par("usr")[1:2] ylim<-par("usr")[3:4] if(is.null(y)) { if(is.list(x)) { # trust me, I'm a list y<-as.vector(x[[2]]) x<-as.vector(x[[1]]) } else stop("both x and y values must be supplied") } xyna<-which(is.na(x) | is.na(y)) if(any(xyna)) { # get rid of any NAs x<-x[-xyna] y<-y[-xyna] } # check for negative values and offset them out xoffset<-yoffset<-0 if(any(x < 0)) { xoffset<-min(x) x<-x-xoffset xlim<-xlim-xoffset } if(any(y < 0)) { yoffset<-min(y) y<-y-yoffset ylim<-ylim-yoffset } # here begins Ray Brownrigg's code ox<-order(x) x<-x[ox] y<-y[ox] x<-c(xlim[1],x,xlim[2]) y<-c(ylim[1],y,ylim[2]) omaxa<-0 halfxspan<-diff(xlim)/2 halfyspan<-diff(ylim)/2 # added braces here for clarity for(i in 1:(length(x)-1)) { for(j in (i+1):length(x)) { x1<-x[i] x2<-x[j] XX<-x2 - x1 # if(XX > halfxspan) break yy<-c(ylim[1],y[(i+1):(j-1)],ylim[2]) oyy<-order(yy) yy<-yy[oyy] dyy<-diff(yy) # whichdyy<-(dyy <= halfyspan) & (dyy >= 0.5*XX) & (dyy <= 2*XX) # the next line fixes the problem with very large empty spaces whichdyy<-(dyy >= 0.5*XX) & (dyy <= 2*XX) wy1<-yy[whichdyy] if(length(wy1) > 0) { wy2<-yy[(1:length(dyy))[whichdyy]+1] k<-which.max(dyy[whichdyy]) maxa<-(x2-x1)*(wy2[k]-wy1[k]) if(maxa > omaxa) { omaxa<-maxa mx1<-x1 mx2<-x2 my1<-wy1[k] my2<-wy2[k] } } } } # if offsets were used, remove them from the final values if(xoffset < 0) { mx1<-mx1+xoffset mx2<-mx2+xoffset } if(yoffset < 0) { my1<-my1+yoffset my2<-my2+yoffset } # return the center of the rectangle return(list(x=(mx1+mx2)/2,y=(my1+my2)/2)) } plotrix/R/ehplot.R0000644000176000001440000000337611554006631013634 0ustar ripleyusersehplot <- function(data, groups, intervals=50, offset=0.1, log=FALSE, median=TRUE, box=FALSE, boxborder="grey50", xlab="groups", ylab="values", col="black", ...) { stopifnot(length(data) == length(groups), is.numeric(data), intervals > 0, offset < 0.4) grps <- split(data, groups, drop=TRUE) dr <- range(data, finite = TRUE) if (log) seps <- dr[1] * exp((0:intervals) * log(dr[2]/dr[1]) / intervals) else seps <- (0:intervals) * (diff(dr) / intervals) + dr[1] # prepare x-shift for odd and even number of datapoints per interval inc <- rep(1:(0.4/offset), each=2) xshift <- list(even=c((inc-0.5) * offset * (-1)^(1:length(inc))), # 1 odd=c(0, inc * offset * (-1)^(1:length(inc)))) # 2 pnts_a <- list() # accumulate datapoint offsets before plotting. for (i in 1:length(grps)) { histo <- hist(grps[[i]], breaks=seps, plot=FALSE)$counts ixof <- unlist(sapply(histo, function(j){rep(xshift[[j%%2 + 1]], length.out=j)})) pnts_a[[i]] <- i + ixof[rank(grps[[i]], ties.method="first")] if (anyDuplicated(na.omit(cbind(grps[[i]], pnts_a[[i]])))) warning("Some points are overplotted in group ",names(grps)[i], ". Please consider using a lower offset-value.") } plot(data, xlim=c(0.5, length(grps)+0.5), xaxt="n", type="n", xlab=xlab, ylab=ylab, log=ifelse(log,"y",""), ...) axis(1, at=1:length(grps), labels=names(grps), ...) if (box) boxplot(data ~ groups, border=boxborder, add=TRUE, axes=FALSE, outline=FALSE) # draw datapoints at once points(unsplit(pnts_a, groups, drop=TRUE), data, col=col, ...) if (median) lines(rep(1:length(grps),each=3)+c(-0.4, 0.4, NA), rep(sapply(grps, median, na.rm=TRUE), each=3)+c(0, 0, NA), lwd=3) } plotrix/R/drawNestedBars.R0000755000176000001440000000455112110347040015237 0ustar ripleyusersdrawNestedBars<-function(x,start,end,shrink=0.1,errbars=FALSE, col=NA,labelcex=1,lineht=NA,showall=TRUE, barlabels=NULL,showlabels=TRUE,arrow.cap=NA) { barcol<-ifelse(is.list(col),col[[1]],col) # may be only one bar per call #if(!is.null(x[[1]][[1]]) && (showall | length(x[[1]]) == 1) && nchar(barlabels[[1]])) if(!is.null(x[[1]][[1]]) && showall) rect(start,0,end,unlist(x[[1]][[1]]),col=barcol) if(showlabels && !is.null(x[[1]][[1]])) { if(!is.null(barlabels)) barlabel<-barlabels[[1]] else barlabel<-names(x[[1]][[1]]) labely<--lineht*length(x[[1]]) # zero length bar label suppresses this if(nchar(barlabels[[1]][1])) { par(xpd=TRUE) segments(c(start,end,start),c(0,0,labely),c(start,end,end),rep(labely,3)) boxed.labels((start+end)/2,labely,barlabel,ypad=1.4, bg=ifelse(is.na(barcol),"white",barcol),cex=labelcex) par(xpd=FALSE) } } if(errbars && length(x[[1]])==1) dispersion((start+end)/2,x[[1]][[1]],x[[2]][[1]],x[[3]][[1]], intervals=errbars<3,arrow.cap=arrow.cap) # remove the first component of each element of x displayed above for(xcomp in 1:length(x)) x[[xcomp]][[1]]<-NULL # if there are any more bars to display, set up the call if(length(x[[1]])) { # number of values in the new first component of x nvalues<-length(unlist(x[[1]][[1]])) # drop the color of the last bar if(is.list(col)) col[[1]]<-NULL # drop the top level barlabels if present if(!is.null(barlabels) && length(barlabels) > 1) barlabels[[1]]<-NULL # width of all the spaces between the next group of bars barspace<-(end-start)*shrink # width of each bar barwidth<-((end-start)-barspace)/nvalues # width of each space between bars barspace<-barspace/(nvalues+1) # step through the values for this group of bars for(nextval in 1:nvalues) { newx<-list() # slice the x arrays for this set of values for(xcomp in 1:length(x)) newx[[xcomp]]<-lapply(x[[xcomp]],sliceArray,nextval) newbarlabels<-barlabels start<-start+barspace newcol<-col if(is.list(col)) newcol[[1]]<-col[[1]][nextval] if(!is.null(barlabels)) newbarlabels[[1]]<-barlabels[[1]][nextval] drawNestedBars(newx,start,start+barwidth,shrink=shrink, errbars=errbars,col=newcol,labelcex=labelcex,lineht=lineht, showall=showall,barlabels=newbarlabels,showlabels=showlabels, arrow.cap=arrow.cap) #else print(newx) start<-start+barwidth } } } plotrix/R/draw.radial.line.R0000644000176000001440000000202511762114277015454 0ustar ripleyusersdraw.radial.line <- function(start, end, center=c(0, 0), angle=0, deg=NA, expand=FALSE, col=NA, lwd=NA, ...) { if (is.na(col)) col <- par("col") if (is.na(lwd)) lwd <- par("lwd") if (is.na(deg)) deg <- angle*180/pi angle <- deg*pi/180 cosang <- cos(angle) sinang <- sin(angle) xylim <- par("usr") plotdim <- par("pin") ymult <- (xylim[4] - xylim[3])/(xylim[2] - xylim[1]) * plotdim[1]/plotdim[2] if (!expand || end <= 0) { px <- c(start, end) lines(center[1]+px*cosang, center[2]+px*sinang*ymult, col=col, lwd=lwd, ...) } else { devunits <- dev.size("px") lwdend <- (lwd/2)*(xylim[2]-xylim[1])/devunits[1] px <- c(start, start, end, end) lwdstart <- lwdend * start/end py <- c(lwdstart, -lwdstart, -lwdend, lwdend) pxt <- center[1] + px*cosang - py*sinang*ymult pyt <- center[2] + px*sinang + py*cosang*ymult polygon(pxt, pyt, border=col, col=col) } } plotrix/R/draw.ellipse.R0000755000176000001440000000451112112006321014710 0ustar ripleyusersdraw.ellipse <- function(x, y, a = 1, b = 1, angle = 0, segment=c(0, 360), arc.only=TRUE, deg = TRUE, nv=100, border=NULL, col=NA, lty=1, lwd=1, ...) { ## workhorse internal function draw ellipse draw1ellipse <- function(x, y, a = 1, b = 1, angle = 0, segment=c(0, 360), arc.only=TRUE, nv = 100, deg = TRUE, border=NULL, col=NA, lty=1, lwd=1, ...) { if (deg) {# if input is in degrees angle <- angle * pi/180 segment <- segment * pi/180 } z <- seq(segment[1], segment[2], length = nv + 1) xx <- a * cos(z) yy <- b * sin(z) alpha <- xyangle(xx, yy, directed = TRUE, deg = FALSE) rad <- sqrt(xx^2 + yy^2) xp <- rad * cos(alpha + angle) + x yp <- rad * sin(alpha + angle) + y if (!arc.only) { xp <- c(x, xp, x) yp <- c(y, yp, y) } polygon(xp, yp, border=border, col=col, lty=lty, lwd=lwd, ...) invisible(NULL) } ## internal function for the internal function xyangle <- function(x, y, directed = FALSE, deg = TRUE) { if (missing(y)) { y <- x[,2] x <- x[,1] } out <- atan2(y, x) if (!directed) out <- out %% pi if (deg) # if output is desired in degrees out <- out * 180 / pi out } if (missing(y)) { y <- x[,2] x <- x[,1] } n <- length(x) if (length(a) < n) a <- rep(a, n)[1:n] if (length(b) < n) b <- rep(b, n)[1:n] if (length(angle) < n) angle <- rep(angle, n)[1:n] if (length(col) < n) col <- rep(col, n)[1:n] if (length(border) < n) border <- rep(border, n)[1:n] if (length(nv) < n) nv <- rep(nv, n)[1:n] if(n==1) draw1ellipse(x,y,a,b,angle=angle,segment=segment, arc.only=arc.only,deg=deg,nv=nv,col=col,border=border, lty=lty,lwd=lwd,...) else { if (length(segment) < 2*n) segment <- matrix(segment[1:2], n, 2, byrow=TRUE) lapply(1:n, function(i) draw1ellipse(x[i], y[i], a[i], b[i], angle=angle[i], segment=segment[i,], arc.only=arc.only, deg=deg, nv=nv[i], col=col[i], border=border[i], lty=lty, lwd=lwd, ...)) } invisible(NULL) } plotrix/R/draw.circle.R0000755000176000001440000000102112112005473014514 0ustar ripleyusersdraw.circle<-function(x,y,radius,nv=100,border=NULL,col=NA,lty=1,lwd=1) { xylim<-par("usr") plotdim<-par("pin") ymult<-(xylim[4]-xylim[3])/(xylim[2]-xylim[1])*plotdim[1]/plotdim[2] angle.inc<-2*pi/nv angles<-seq(0,2*pi-angle.inc,by=angle.inc) if(length(col) < length(radius)) col<-rep(col,length.out=length(radius)) for(circle in 1:length(radius)) { xv<-cos(angles)*radius[circle]+x yv<-sin(angles)*radius[circle]*ymult+y polygon(xv,yv,border=border,col=col[circle],lty=lty,lwd=lwd) } invisible(list(x=xv,y=yv)) } plotrix/R/draw.arc.R0000755000176000001440000000406211762341401014034 0ustar ripleyusersdraw.arc <- function(x=1, y=NULL, radius=1, angle1=deg1*pi/180, angle2=deg2*pi/180, deg1=0, deg2=45, n=0.05, col=NA, lwd=NA, ...) { if (all(is.na(col))) col <- par("col") if (all(is.na(lwd))) lwd <- par("lwd") xylim <- par("usr") plotdim <- par("pin") ymult <- (xylim[4] - xylim[3])/(xylim[2] - xylim[1]) * plotdim[1]/plotdim[2] devunits <- dev.size("px") draw.arc.0 <- function(x, y, radius, angle1, angle2, n, col, lwd, ...) { delta.angle <- (angle2 - angle1) if (n != as.integer(n)) n <- as.integer(1+delta.angle/n) # Divide total angle by desired segment angle to get number of segments delta.angle <- delta.angle/n angleS <- angle1 + seq(0, length=n) * delta.angle angleE <- c(angleS[-1], angle2) # Move segment starts/ends so that segments overlap enough to make wide segments # not have an open slice in them. The slice is open by delta.angle*half.lwd.user. # That subtends an angle of that/(radius+half.lwd.user) radians, from center. # Move segment endpoints by half of that, so together they equal that. if (n > 1) { half.lwd.user <- (lwd/2)*(xylim[2]-xylim[1])/devunits[1] adj.angle = delta.angle*half.lwd.user/(2*(radius+half.lwd.user)) angleS[2:n] = angleS[2:n] - adj.angle angleE[1:(n-1)] = angleE[1:(n-1)] + adj.angle } p1x <- x + radius * cos(angleS) p1y <- y + radius * sin(angleS) * ymult p2x <- x + radius * cos(angleE) p2y <- y + radius * sin(angleE) * ymult segments(p1x, p1y, p2x, p2y, col=col, lwd=lwd, ...) } xy <- xy.coords(x, y) x <- xy$x y <- xy$y a1 <- pmin(angle1, angle2) a2 <- pmax(angle1, angle2) angle1 <- a1 angle2 <- a2 args <- data.frame(x, y, radius, angle1, angle2, n, col, lwd, stringsAsFactors=FALSE) for (i in 1:nrow(args)) do.call("draw.arc.0", c(args[i, ], ...)) invisible(args) } plotrix/R/dotplot.mtb.R0000755000176000001440000000365411621167460014614 0ustar ripleyusersdotplot.mtb <- function (x, xlim = NULL, main = NULL, xlab = NULL, ylab=NULL, pch = 19, hist=FALSE, yaxis=FALSE, mtbstyle=TRUE) { if (is.null(xlim)) xlim <- range(pretty(range(x,na.rm=TRUE))) if (is.null(main)) main <- "" if (is.null(xlab)) xlab <- "" if (is.null(ylab)) ylab <- "" x <- sort(x) w <- table(x) if(hist) { x <- as.numeric(names(w)) w <- unname(unclass(w)) } else w <- unlist(lapply(w, function(n) { 1:n })) mw <- max(w) Nmax <- floor(par()$pin[2]/strheight("o",units="inches")) top <- if(mtbstyle) Nmax/2 else Nmax if(mw <= top & !hist) { plot(range(x, na.rm = TRUE), c(0, 1), type = "n", xlab = "", ylab = "", xlim = xlim, main = main, axes = FALSE) yr <- if(mtbstyle) c(-Nmax/2,Nmax/2) else c(0,Nmax) par(usr = c(par()$usr[1:2], yr[1], yr[2])) y <- strheight("o") * w points(x, y, pch = pch) axis(side = 1, pos = 0) if(xlab!="") axis(side=1,at=0.5*sum(xlim),pos=-2,labels=xlab,tick=FALSE) if(ylab!="") axis(side=2,at=0.5*yr[2],line=2,labels=ylab,tick=FALSE) if(yaxis) { b <- max(1,ceiling(top/10)) ll <- 1+floor(top/b) at <- seq(0,by=b,length=ll) axis(side = 2,at=at) } } else { nt <- mw+1 yr <- if(mtbstyle) c(-nt,nt) else c(0,nt) if(hist) plot(x,w,type="h",xlab="",ylab="",xlim=xlim, ylim=yr,main=main,axes=FALSE) else plot(x,w,pch=pch,xlab="",ylab="",xlim=xlim, ylim=yr,main=main,axes=FALSE) pos <- if(mtbstyle) -0.02*mw else 0 axis(side = 1,pos = pos) if(mtbstyle) { if(xlab!="") axis(side=1,at=0.5*sum(xlim),pos=-2,labels=xlab,tick=FALSE) if(ylab!="") axis(side=2,at=0.5*yr[2],line=2,labels=ylab,tick=FALSE) } else { if(xlab!="") title(xlab=xlab) if(ylab!="") title(ylab=ylab) } if(yaxis) { b <- max(1,ceiling(nt/10)) ll <- 1+floor(nt/b) at <- seq(0,by=b,length=ll) axis(side = 2,at=at) } } } plotrix/R/display.overplot.R0000644000176000001440000000422112041462673015651 0ustar ripleyusersfind_overplots<-function(x,y,tol) { xlen<-length(x) flags<-1:xlen xsep<-ysep<-xdup<-ydup<-xydup<-rep(NA,xlen) nsep<-ndup<-0 for(i in 1:xlen) { if(!is.na(flags[i])) { dups<-abs(x - x[i]) <= tol[1] & abs(y - y[i]) <= tol[2] ndups<-sum(dups,na.rm=TRUE) if(ndups > 1) { ndup<-ndup + 1 xydup[ndup]<-ndups xdup[ndup]<-x[i] ydup[ndup]<-y[i] } else { nsep<-nsep + 1 xsep[nsep]<-x[i] ysep[nsep]<-y[i] } } flags[dups]<-NA } return(list(xsep=xsep,ysep=ysep,xdup=xdup,ydup=ydup,xydup=xydup)) } display.overplots<-function(x,y,tol=NULL,how=c("count","cluster","size"), xlim=NULL,ylim=NULL,col=rep(par("fg"),2),pch=c("1",1),spc=NULL,...) { if(missing(x)) stop("display.overplots must have xy coordinates") dimx<-dim(x) if(missing(y)) { if(is.list(x) && names(x)[1] == "x") { y<-x[[2]] x<-x[[1]] } else { if(!is.null(dimx)) { y<-x[,2] x<-x[,1] } } } if(any(is.na(x) | is.na(y))) { indices<-!is.na(x) & !is.na(y) x<-x[indices] y<-y[indices] } if(is.null(xlim)) xlim<-range(x) if(is.null(ylim)) ylim<-range(y) xlen<-length(x) if(xlen != length(y)) stop("x and y must be the same length.") plot(x,y,type="n",axes=FALSE,xlab="",ylab="") xylim<-par("usr") if(is.null(tol)) tol<-c(diff(xylim[1:2]/100),diff(xylim[3:4]/100)) else if(length(tol) == 1) tol <- rep(tol,2) if(length(col) < xlen) col<-rep(col,xlen) if(length(pch) < xlen) pch<-rep(pch,xlen) if(is.null(spc)) spc<-c(diff(xylim[1:2])/100,diff(xylim[3:4]/100)) xy<-find_overplots(x,y,tol) plot(xy$xsep,xy$ysep,xlim=xlim,ylim=ylim,col=col[1],pch=pch[1],...) if(how[1] == "count") text(xy$xdup,xy$ydup,xy$xydup,col=col[2],...) if(how[1] == "cluster") { xshifts<-c(0,-spc[1],spc[1],0,0,-spc[1],spc[1],-spc[1],spc[1]) yshifts<-c(0,0,0,-spc[2],spc[2],-spc[2],spc[2],spc[2],-spc[2]) for(dup in 1:sum(!is.na(xy$xdup))) { for(ndups in 1:min(c(xy$xydup[dup],9))) { points(xy$xdup[dup]+xshifts[ndups],xy$ydup[dup]+yshifts[ndups], pch=pch[2],col=col[2],...) } if(xy$xydup[dup] > 9) points(xy$xdup[dup],xy$ydup[dup],pch=4,cex=2) } } if(how[1] == "size") points(xy$xdup,xy$ydup,pch=pch[2],col=col[2],cex=sqrt(xy$xydup)) } plotrix/R/dispersion.R0000755000176000001440000000403111704224504014506 0ustar ripleyusersdispersion<-function (x,y,ulim,llim=ulim,intervals=TRUE, arrow.cap=0.01,arrow.gap=NA,type="a",fill=NA,lty=NA,pch=NA, border=NA,display.na=TRUE,...) { if(is.list(x) && length(x[[1]]) == length(x[[2]])) { y<-x$y x<-x$x } if(missing(y) && !missing(x)) { y<-x x<-1:length(x) } # if absolute values are passed, convert them to intervals if(!intervals) { llim<-y-llim ulim<-ulim-y } plotlim<-par("usr") npoints<-length(x) if(is.na(arrow.gap)) arrow.gap<-strheight("O")/1.5 for(i in 1:npoints) { if(toupper(type) == "A") { if(!is.na(llim[i])) { if(arrow.gap >= llim[i] * 0.9) { caplen<-arrow.cap * diff(par("usr")[1:2]) x0<-x[i]-caplen x1<-x[i]+caplen y0<-rep(y[i]-llim[i],2) y1<-rep(y[i]-llim[i],2) segments(x0,y0,x1,y1,...) } else { caplen<-arrow.cap*par("pin")[1] x0<-x1<-rep(x[i],2) y0<-y[i]-arrow.gap y1<-y[i]-llim[i] arrows(x0,y0,x1,y1,length=caplen,angle=90,...) } } else { if(display.na) { x0<-x1<-rep(x[i],2) y0<-y[i]-arrow.gap y1<-plotlim[3] segments(x0,y0,x1,y1,...) } } if(!is.na(ulim[i])) { if(arrow.gap >= ulim[i] * 0.9) { caplen<-arrow.cap * diff(par("usr")[1:2]) x0<-x[i]-caplen x1<-x[i]+caplen y0<-rep(y[i]+ulim[i],2) y1<-rep(y[i]+ulim[i],2) segments(x0,y0,x1,y1,...) } else { caplen<-arrow.cap*par("pin")[1] x0<-x1<-rep(x[i],2) y0<-y[i]+arrow.gap y1<-y[i]+ulim[i] arrows(x0,y0,x1,y1,length=caplen,angle=90,...) } } else { if(display.na) { x0<-x1<-rep(x[i],2) y0<-y[i]+arrow.gap y1<-plotlim[4] segments(x0,y0,x1,y1,...) } } } } if(toupper(type) == "L") { if(!is.na(fill)) { polygon(c(x,rev(x)),c(y+ulim,rev(y-llim)),col=fill,border=NA) if(!is.na(pch)) { if(is.na(lty)) points(x,y,pch=pch) else lines(x,y,lty=lty,pch=pch,type="b") } else { if(!is.na(lty)) lines(x,y,lty=lty) } } if(!is.na(border)) { lines(x,y+ulim,lty=border,...) lines(x,y-llim,lty=border,...) } } } plotrix/R/diamondplot.R0000755000176000001440000000334011144531312014637 0ustar ripleyusersdiamondplot<-function(x, bg=gray(0.6), col=rainbow,name="", ...) { if(!is.data.frame(x)) stop("Argument has to be a data frame") ## read original graphical parms opar<-par(no.readonly = TRUE) ## set background par(bg=bg) prop<-0.8 scale<-5 ## define aux. functions ## degrees to radiants deg2rad<-function(alfa) { (alfa*pi)/180 } ## normalize data w.r.t. maximum normalizza<-function(x){ x/max(x) } ## find points' coordinates coord<-function(x, prop=17) { n<-length(x) alfa<-rep(NA,n) for (i in 1:n) { alfa[i]<-360/n*i } c.x<-sin(deg2rad(alfa))*x*prop c.y<-cos(deg2rad(alfa))*x*prop list(x=c.x,y=c.y) } ## plot n segments originating from the origin(!) segmenti<-function(n, prop=1, labels=NULL,scale=5) { plot(0,0,axes=FALSE,xlab="",ylab="",main=name,...) for(i in 1:n) { alfa<-360/n*i x1<-c(0,sin(deg2rad(alfa))*prop) y1<-c(0,cos(deg2rad(alfa))*prop) polygon(x1,y1) text(sin(deg2rad(alfa)),cos(deg2rad(alfa)),labels[i],cex=0.8) } for (i in 1:n) { alfa<-360/n*i for( j in 1:scale) { xa<-(sin(deg2rad(alfa))*(1/scale)*j*prop) ya<-(cos(deg2rad(alfa))*(1/scale)*j*prop) points(xa,ya,pch=19) et<-round((1/scale)*j*17) text(sin(deg2rad(0))+0.1,cos(deg2rad(0))*(1/scale)*j*prop,et,cex=0.8) } } } n<-dim(x)[[1]] k<-dim(x)[[2]] segmenti(n, prop=prop, labels=rownames(x)) for (j in 1:k) { polygon(coord(normalizza(x[,j]), prop=prop), lty=j, border=col(k)[j]) } legend(-1.05,1.05,legend=dimnames(x)[[2]],lty=1:k,col=col(k),cex=0.8) ## ripristinate original graph parms par(opar) } plotrix/R/dendroPlot.R0000644000176000001440000000335611552520206014446 0ustar ripleyusersdendroPlot<-function(x,breaks=list(10,10,10),pch=1,col=par("fg"),cex=1,nudge=NA, setlabels=NA,...) { plot(c(0.5,length(x)+0.5),range(unlist(sapply(x,as.numeric))), type="n",xaxt="n",...) lenx<-length(x) if(is.na(setlabels[1])) setlabels<-paste("Group",1:lenx) axis(1,at=1:lenx,labels=setlabels) if(is.na(nudge[1])) nudge<-strwidth("o") if(length(pch) < lenx) pch<-rep(pch,length.out=lenx) if(length(col) < lenx) col<-rep(col,length.out=lenx) for(list_element in 1:length(x)) { if(is.character(x[[list_element]])) x[[list_element]]<-factor(x[[list_element]]) if(is.factor(x[[list_element]])) nbins<-length(levels(x[[list_element]])) else { xbreaks<-cut(x[[list_element]],breaks=breaks[[list_element]]) nbins<-length(levels(xbreaks)) } for(bin in 1:nbins) { if(is.factor(x[[list_element]])) { thisbin<-which(as.numeric(x[[list_element]])==bin) npoints<-length(thisbin) } else { thisbin<-which(as.numeric(xbreaks)==bin) npoints<-length(thisbin) } if(npoints) { if(npoints==1) offsetx<-offsety<-0 else { offsetx<-(c(0,trunc(seq(1,npoints/2,by=0.5)))*nudge[1])[1:npoints] # only apply the vertical nudge for factors if(length(nudge) > 1 && is.factor(x[[list_element]])) offsety<-c(0,rep(c(nudge[2],nudge[2],-nudge[2],-nudge[2]), length.out=npoints-1)) else offsety<-rep(0,length(offsetx)) } if(length(offsetx) > 3 ) offsetx[seq(2,length(offsetx),by=2)]<- -offsetx[seq(2,length(offsetx),by=2)] else if(length(offsetx) == 3 ) offsetx[2]<--offsetx[2] points(list_element+offsetx, sort(as.numeric(x[[list_element]][thisbin]))+offsety, pch=pch[list_element],col=col[list_element]) } } } } plotrix/R/dendrite.R0000755000176000001440000000360411512554757014147 0ustar ripleyusersmakeDendrite<-function(x) { dimx<-dim(x) if (is.null(dimx)) { dend.tab<-table(as.character(x),useNA="ifany") tablen<-length(dend.tab) dendrite<-vector("list",tablen) for(i in 1:tablen) dendrite[[i]]<-list(dend.tab[i],NULL) } else { dend.tab<- table(as.character(x[, 1]),useNA="ifany") tablen<-length(dend.tab) tabname<-names(dend.tab) dendrite<-vector("list",tablen) for(i in 1:tablen) { if(is.na(tabname[i])) nextx<-x[is.na(x[,1]),2:dimx[2]] else nextx<-x[as.character(x[,1])==tabname[i]&!is.na(x[,1]),2:dimx[2]] dendrite[[i]] <- list(dend.tab[i], makeDendrite(nextx)) } } class(dendrite) <- "dendrite" return(dendrite) } sumDendrite<-function(x) { dsum<-0 for(i in 1:length(x)) dsum<-dsum+x[[i]][[1]] return(dsum) } furc<-function(x,xpos,yrange,toplevel,cex=1) { xlen<-length(x) if(xlen) { yinc<-diff(yrange)/xlen ypos<-seq(yrange[1] + yinc/2, yrange[2] - yinc/2,length.out=xlen) if(!toplevel) { segments(xpos-0.5,ypos[1],xpos-0.5,ypos[length(ypos)]) segments(xpos-0.5,ypos,xpos,ypos) } for(i in 1:xlen) { if(is.list(x[[i]][[2]])) { segments(xpos,ypos[i],xpos+0.5,ypos[i]) furc(x[[i]][[2]],xpos+1,c(ypos[i]-yinc/2, ypos[i]+yinc/2),FALSE,cex=cex) } boxed.labels(xpos,ypos[i],paste(names(x[[i]][[1]]), x[[i]][[1]]),cex=cex) } } } listDepth<-function(x) { if(is.list(x)) { maxdepth<-1 for(lindex in 1:length(x)) { newdepth<-listDepth(x[[lindex]])+1 if(newdepth > maxdepth) maxdepth<-newdepth } } else maxdepth<-0 return(maxdepth) } plot.dendrite<-function(x,xlabels=NULL,main="",mar=c(1,0,3,0),cex=1,...) { oldmar<-par("mar") par(mar=mar) xmax<-listDepth(x)/2 ymax<-sumDendrite(x) plot(0,main=main,xlim=c(0,xmax),ylim=c(1,ymax), xlab="",ylab="",type="n",axes=FALSE,...) par(xpd=TRUE) text(seq(0.5,xmax),par("usr")[3],xlabels) par(xpd=FALSE) furc(x,0.5,c(1,ymax),TRUE,cex=cex) par(mar=oldmar) } plotrix/R/cylindrect.R0000755000176000001440000000111511056465626014503 0ustar ripleyuserscylindrect<-function(xleft,ybottom,xright,ytop,col,border=NA,gradient="x", nslices=50) { rgbval<-col2rgb(col)/255 maxrgb<-max(rgbval) cols<-matrix(0,nrow=3,ncol=6) for(i in 1:3) { if(rgbval[i] == maxrgb) delta<-1-rgbval[i] else delta<-(1-0.2*(maxrgb-rgbval[i])/sum(maxrgb-rgbval))-rgbval[i] cols[i,]<-c(rgbval[i]+0.3*delta,rgbval[i]+0.6*delta,rgbval[i]+0.9*delta, rgbval[i]+0.6*delta,rgbval[i]+0.3*delta,rgbval[i]) } gradient.rect(xleft,ybottom,xright,ytop,cols[1,],cols[2,],cols[3,], gradient=gradient,nslices=nslices,border=border) invisible(cols) } plotrix/R/count.overplot.R0000755000176000001440000000256311470154010015332 0ustar ripleyuserscount.overplot<-function(x,y,tol=NULL,col=par("fg"),pch="1",...) { if(missing(x)) stop("Usage: count.overplot(x,y,tol=NULL,...)") dimx<-dim(x) if(missing(y)) { if(is.list(x) && names(x)[1] == "x") { y<-x[[2]] x<-x[[1]] } else { if(!is.null(dimx)) { y<-x[,2] x<-x[,1] } } } if(any(is.na(x) | is.na(y))) { indices<-!is.na(x) & !is.na(y) x<-x[indices] y<-y[indices] } xlim<-range(x) ylim<-range(y) xlen<-length(x) if(xlen != length(y)) stop("x and y must be the same length.") if(is.null(tol)) { plot(x,y,type="n",axes=FALSE,xlab="",ylab="") tol<-c(strwidth("o")/2,strheight("o")/2) } else { if (length(tol) == 1) tol <- rep(tol,2) } if(length(col) < xlen) col<-rep(col,xlen) if(length(pch) < xlen) pch<-rep(pch,xlen) flags<-1:xlen xsep<-ysep<-xdup<-ydup<-xydup<-sepcol<-seppch<-rep(0,xlen) nsep<-ndup<-0 for(i in 1:xlen) { if(!is.na(flags[i])) { dups<-abs(x - x[i]) <= tol[1] & abs(y - y[i]) <= tol[2] ndups<-sum(dups) if(ndups > 1) { ndup<-ndup + 1 xydup[ndup]<-ndups xdup[ndup]<-x[i] ydup[ndup]<-y[i] } else { nsep<-nsep + 1 xsep[nsep]<-x[i] ysep[nsep]<-y[i] sepcol[nsep]<-col[i] seppch[nsep]<-pch[i] } } flags[dups]<-NA } plot(xsep[1:nsep],ysep[1:nsep],xlim=xlim,ylim=ylim, col=sepcol[1:nsep],pch=seppch[1:nsep],...) text(xdup[1:ndup],ydup[1:ndup],xydup[1:ndup],...) } plotrix/R/corner.label.R0000755000176000001440000000124211154421464014701 0ustar ripleyuserscorner.label<-function(label=NULL,x=-1,y=1,xoff=NA,yoff=NA,figcorner=FALSE,...) { if(is.na(xoff)) xoff<-strwidth("m")/2 if(is.na(yoff)) yoff<-strheight("m")/2 par.usr<-par("usr") xpos<-par.usr[(3+x)/2] ypos<-par.usr[(3+y)/2+2] if(figcorner) { par.pin<-par("pin") xplotrange<-par.usr[2]-par.usr[1] yplotrange<-par.usr[4]-par.usr[3] par.mai<-par("mai") xmar<-xplotrange*par.mai[3+x]/par.pin[1] ymar<-yplotrange*par.mai[2+y]/par.pin[2] xpos<-xpos+x*xmar ypos<-ypos+y*ymar } if(!is.null(label)) { if(figcorner) par(xpd=TRUE) text(xpos-x*xoff,ypos-y*yoff,label,adj=c((1+x)/2,(1+y)/2)) if(figcorner) par(xpd=FALSE) } return(list(x=xpos,y=ypos)) } plotrix/R/color2D.matplot.R0000755000176000001440000000733511676535501015336 0ustar ripleyusershexagon<-function(x,y,unitcell=1,col=NA,border="black") { polygon(c(x,x,x+unitcell/2,x+unitcell,x+unitcell,x+unitcell/2), c(y+unitcell*0.125,y+unitcell*0.875,y+unitcell*1.125,y+unitcell*0.875, y+unitcell*0.125,y-unitcell*0.125),col=col,border=border) } color2D.matplot<-function(x,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1), extremes=NA,cellcolors=NA,show.legend=FALSE,nslices=10,xlab="Column", ylab="Row",do.hex=FALSE,axes=TRUE,show.values=FALSE,vcol=NA,vcex=1, border="black",na.color=NA,xrange=NULL,color.spec="rgb",yrev=TRUE, xat=NULL,yat=NULL,Hinton=FALSE,...) { if(is.matrix(x) || is.data.frame(x)) { xdim<-dim(x) if(is.data.frame(x)) x<-unlist(x) else x<-as.vector(x) oldpar<-par("xaxs","yaxs","xpd","mar") par(xaxs="i",yaxs="i") if(do.hex) par(mar=c(5,4,4,4)) plot(c(0,xdim[2]),c(0,xdim[1]),xlab=xlab,ylab=ylab,type="n",axes=FALSE,...) oldpar$usr<-par("usr") if(!do.hex) { box() pos<-0 } else pos<- -0.3 if(axes) { if(is.null(xat)) xat<-pretty(0:xdim[2])[-1] axis(1,at=xat-0.5,labels=xat,pos=pos) if(is.null(yat)) yat<-pretty(0:xdim[1])[-1] axis(2,at=xdim[1]-yat+0.5,labels=yat) } if(all(is.na(cellcolors))) { if(Hinton) { if(is.na(extremes[1])) extremes<-c("black","white") cellcolors<-extremes[(x > 0) + 1] } else cellcolors<-color.scale(x,cs1,cs2,cs3,extremes=extremes, na.color=na.color,color.spec=color.spec) } # this sets the color for overprinted text to black or white # depending upon what color will be the background for the text if(is.na(vcol)) vcol<-ifelse(colSums(col2rgb(cellcolors)*c(1,1.4,0.6))<350,"white","black") # if it's a Hinton diagram,cellsize = x, rescaling to 0,1 if necessary if(Hinton) { if(any(x < 0 | x > 1)) cellsize<-matrix(rescale(abs(x),c(0,1)),nrow=xdim[1]) } else cellsize<-matrix(1,nrow=xdim[1],ncol=xdim[2]) # start from the top left - isomorphic with the matrix layout if(do.hex) { par(xpd=TRUE) offset<-0 if(length(border) < xdim[1]*xdim[2]) border<-rep(border,length.out=xdim[1]*xdim[2]) for(row in 1:xdim[1]) { for(column in 0:(xdim[2]-1)) { hexagon(column+offset,xdim[1]-row,unitcell=cellsize[row,column+1], col=cellcolors[row+xdim[1]*column], border=border[row+xdim[1]*column]) if(show.values) text(column+offset+0.5,xdim[1]-row+0.5,x[row+column*xdim[1]], col=vcol[row+xdim[1]*column],cex=vcex) } offset<-ifelse(offset,0,0.5) } par(xpd=FALSE) } else { if(Hinton) inset<-(1-cellsize)/2 else inset<-0 if(yrev) { y0<-rep(seq(xdim[1]-1,0,by=-1),xdim[2])+inset y1<-rep(seq(xdim[1],1,by=-1),xdim[2])-inset } else { y0<-rep(0:(xdim[1]-1),xdim[2])+inset y1<-rep(1:xdim[1],xdim[2])-inset } rect(sort(rep((1:xdim[2])-1,xdim[1]))+inset,y0, sort(rep(1:xdim[2],xdim[1]))-inset,y1, col=cellcolors,border=border) if(show.values) { if(yrev) texty<-rep(seq(xdim[1]-0.5,0,by=-1),xdim[2]) else texty<-rep(seq(0.5,xdim[1]-0.5,by=1),xdim[2]) text(sort(rep((1:xdim[2])-0.5,xdim[1])),texty, round(x,show.values),col=vcol,cex=vcex) } } naxs<-which(is.na(x)) xy<-par("usr") plot.din<-par("din") plot.pin<-par("pin") bottom.gap<-(xy[3]-xy[4])*(plot.din[2]-plot.pin[2])/(2*plot.pin[2]) grx1<-xy[1] gry1<-bottom.gap*0.95 grx2<-xy[1]+(xy[2]-xy[1])/4 gry2<-bottom.gap*0.8 if(length(cellcolors) > 1) { colmat<-col2rgb(c(cellcolors[which.min(x)],cellcolors[which.max(x)])) cs1<-colmat[1,]/255 cs2<-colmat[2,]/255 cs3<-colmat[3,]/255 color.spec<-"rgb" } rect.col<-color.scale(1:nslices,cs1,cs2,cs3,color.spec=color.spec) if(show.legend) color.legend(grx1,gry1,grx2,gry2,round(range(x,na.rm=TRUE),show.legend), rect.col=rect.col) par(oldpar) } else cat("x must be a data frame or matrix\n") } plotrix/R/color.scale.lines.R0000755000176000001440000000136211056465626015664 0ustar ripleyuserscolor.scale.lines<-function(x,y,reds,greens,blues,col=NA,colvar=NA,...) { if(is.list(x) && missing(y)) { y<-x$y x<-x$x } lenx<-length(x) leny<-length(y) nseg<-lenx-1 if(lenx != leny) { warning("x and y are different lengths - some values will be ignored") if(lenx>leny) nseg<-leny-1 } if(is.na(col[1])) { # if colors are not supplied if(is.na(colvar[1])) # if a separate variable is not supplied, use running average of y pairs lcol<-color.scale((y[1:nseg]+y[2:(nseg+1)])/2,reds,greens,blues) # assume that colvar refers to the intervals, not the x/y points else lcol<-color.scale(colvar,reds,greens,blues) } else lcol=col segments(x[1:nseg],y[1:nseg],x[2:(nseg+1)],y[2:(nseg+1)],col=lcol,...) } plotrix/R/color.scale.R0000755000176000001440000000423111617740536014550 0ustar ripleyuserscolor.scale<-function(x,cs1=c(0,1),cs2=c(0,1),cs3=c(0,1),alpha=1, extremes=NA,na.color=NA,xrange=NULL,color.spec="rgb") { naxs<-is.na(x) if(!is.na(extremes[1])){ # calculate the color ranges from the extremes - only for rgb colmat<-col2rgb(extremes) cs1<-colmat[1,]/255 cs2<-colmat[2,]/255 cs3<-colmat[3,]/255 color_spec<-"rgb" } maxcs1<-ifelse(color.spec=="hcl",360,1) maxcs2<-ifelse(color.spec=="hcl",100,1) maxcs3<-ifelse(color.spec=="hcl",100,1) ncolors<-length(x) if(is.null(xrange)) { xrange<-range(x,na.rm=TRUE) drop.extremes<-FALSE } else { if(xrange[1] > min(x,na.rm=TRUE) || xrange[2] < max(x,na.rm=TRUE)) stop("An explicit range for x must include the range of x values.") x<-c(xrange,x) drop.extremes=TRUE } ncs1<-length(cs1) if(ncs1>1) { cs1s<-rep(cs1[ncs1],ncolors) xstart<-xrange[1] xinc<-diff(xrange)/(ncs1-1) for(seg in 1:(ncs1-1)){ segindex<-which((x >= xstart) & (x <= (xstart+xinc))) cs1s[segindex]<-rescale(x[segindex],cs1[c(seg,seg+1)]) xstart<-xstart+xinc } if(min(cs1s) < 0 || max(cs1s) > maxcs1) cs1s<-rescale(cs1s,c(0,maxcs1)) } else cs1s<-rep(cs1,ncolors) ncs2<-length(cs2) if(ncs2>1) { cs2s<-rep(cs2[ncs2],ncolors) xstart<-xrange[1] xinc<-diff(xrange)/(ncs2-1) for(seg in 1:(ncs2-1)){ segindex<-which((x >= xstart) & (x <= (xstart+xinc))) cs2s[segindex]<-rescale(x[segindex],cs2[c(seg,seg+1)]) xstart<-xstart+xinc } if(min(cs2s) < 0 || max(cs2s) > maxcs2) cs2s<-rescale(cs2s,c(0,maxcs2)) } else cs2s<-rep(cs2,ncolors) ncs3<-length(cs3) if(ncs3>1) { cs3s<-rep(cs3[ncs3],ncolors) xstart<-xrange[1] xinc<-diff(xrange)/(ncs3-1) for(seg in 1:(ncs3-1)){ segindex<-which((x >= xstart) & (x <= (xstart+xinc))) cs3s[segindex]<-rescale(x[segindex],cs3[c(seg,seg+1)]) xstart<-xstart+xinc } if(min(cs3s) < 0 || max(cs3s) > maxcs3) cs3s<-rescale(cs3s,c(0,maxcs3)) } else cs3s<-rep(cs3,ncolors) if(drop.extremes) { cs1s<-cs1s[-(1:2)] cs2s<-cs2s[-(1:2)] cs3s<-cs3s[-(1:2)] } xdim<-dim(x) colors<-do.call(color.spec,list(cs1s,cs2s,cs3s,alpha=alpha)) if(!is.null(xdim)) colors<-matrix(colors,nrow=xdim[1]) if(length(naxs)) colors[naxs]<-na.color return(colors) } plotrix/R/color.legend.R0000755000176000001440000000165511556522747014732 0ustar ripleyuserscolor.legend<-function (xl,yb,xr,yt,legend,rect.col,cex=1,align="lt", gradient="x",...) { oldcex<-par("cex") par(xpd=TRUE,cex=cex) gradient.rect(xl,yb,xr,yt,col=rect.col,nslices=length(rect.col), gradient=gradient) if(gradient == "x") { xsqueeze<-(xr-xl)/(2*length(rect.col)) textx<-seq(xl+xsqueeze,xr-xsqueeze,length.out=length(legend)) if(match(align,"rb",0)) { texty<-yb-0.2*strheight("O") textadj<-c(0.5,1) } else { # assume it's the default texty<-yt+0.2*strheight("O") textadj<-c(0.5,0) } } else { ysqueeze<-(yt-yb)/(2*length(rect.col)) texty<-seq(yb+ysqueeze,yt-ysqueeze,length.out=length(legend)) if(match(align,"rb",0)) { textx<-xr+0.2*strwidth("O") textadj<-c(0,0.5) } else { # assume it's the default textx<-xl-0.2*strwidth("O") textadj<-c(1,0.5) } } text(textx,texty,labels=legend,adj=textadj,...) par(xpd=FALSE,cex=oldcex) } plotrix/R/color.id.R0000755000176000001440000000025311056465626014056 0ustar ripleyuserscolor.id<-function(col) { c2 <- col2rgb(col) coltab <- col2rgb(colors()) cdist <- apply(coltab, 2, function(z) sum((z - c2)^2)) colors()[which(cdist == min(cdist))] } plotrix/R/color.gradient.R0000755000176000001440000000015511056465626015260 0ustar ripleyuserscolor.gradient<-function(reds,greens,blues,nslices=50) { return(color.scale(1:nslices,reds,greens,blues)) } plotrix/R/cluster.overplot.R0000755000176000001440000000202211070112200015640 0ustar ripleyuserscluster.overplot<-function(x,y,away=NULL,tol=NULL,...) { if(missing(x)) stop("Usage: cluster.overplot(x,y,away=NULL,tol=NULL)") dimx<-dim(x) if(missing(y) && !is.null(dimx)) { y<-x[,2] x<-x[,1] } xlen<-length(x) if(xlen != length(y)) stop("x and y must be the same length.") if(is.null(away)) { plot(x,y,main="",xlab="",ylab="",axes=FALSE,type="n") away<-c(strwidth("o"),5*strheight("o")/8) } if(is.null(tol)) tol<-c(strwidth("o")/2,strheight("o")/2) away.x<-c(0,-away[1],away[1],0,0,-away[1],away[1],-away[1],away[1]) away.y<-c(0,0,0,-away[2],away[2],-away[2],away[2],away[2],-away[2]) flags<-1:xlen for(i in 1:xlen) { if(!is.na(flags[i])) { overplots<-abs(x-x[i]) <= tol[1] & abs(y - y[i]) <= tol[2] if(sum(overplots) > 1) { away.index<-1 for(j in 1:xlen) { if(overplots[j]) { x[j]<-x[j]+away.x[away.index] y[j]<-y[j]+away.y[away.index] away.index<-away.index+1 if(away.index > 9) away.index<-1 } } } } flags[overplots] <- NA } return(list(x=x,y=y,...)) } plotrix/R/clplot.R0000755000176000001440000001220411103270544013623 0ustar ripleyusers# CLPLOT # 20 Oct. 2008 Now plots even pathological data sets without gaps # Parameters: # levels-- vector of desired cutpoints. Program will sort them. # cols-- vector of desired color sequence (strings or numeric references) # x, y-- The data, of course. # '...' is intended for arguments to pass to PLOT or LINES calls # lty-- plot parameter lty (see par() ) # showcuts-- Set to TRUE to plot gridlines at color cut levels # # Note: warning message if levels[j] is outside range(y), but won't terminate or # modify levels clplot<-function(x,y,ylab=deparse(substitute(y)),xlab=deparse(substitute(x)), levels=seq(min(y)+(max(y)-min(y))/5,max(y)-(max(y)-min(y))/5,length.out=4), cols=c("black","blue","green","orange","red"),lty=1,showcuts=FALSE,...) { if(missing(y)){ ylab=deparse(substitute(x)) y<-as.numeric(x) x<-seq(1,length(y)) } xx<-as.numeric(x) yy<-as.numeric(y) #sort to be sure I catch the max and min levels<-sort(as.numeric(levels)) if (levels[1]max(yy)) { cat('Warning: levels value(s) outside data range\n') } # set cols length to number of cuts. (number of colors to be used) if (length(levels)>=length(cols)) { cat("Warning: not enough colors. Will repeat.\n") } cols<-rep(cols,length.out=length(levels)+1) # add "top" and "bottom" cut values to simplify loop; cuts<-sort(c(min(yy),levels,max(yy))) #build 'empty' graph plot(xx,yy,type='n', xlab=xlab, ylab=ylab, ...) # initialize the list variable which will hold all modded slices modslice<-list() newxx<-xx newyy<-yy # newxx/yy will add new points as generated for each slice for(jj in 1 : (length(cuts)-1)) { botsl<-(cuts[jj]>newyy) topsl<-(cuts[jj+1]1 ) { for (i in 1:(length(runs$lengths)-1)) { thepos<-thepos+runs$lengths[i] # "add" interp point at the end of each run # whichway chooses which 'side' of interval to interpolate towards whichway<-slicelog[thepos] #pick correct cut value - is subslice is going up or down #whichcut chooses the cut to use whichcut<-as.logical(newyy[thepos]>=cuts[j]&newyy[thepos+1]>=cuts[j]) #note the interpolation is TO x FROM y xint3<-approx(c(newyy[thepos:(thepos+1)]),c(newxx[thepos:(thepos+1)]),cuts[j+whichcut]) newx <-xint3$y newy <-cuts[j+whichcut] # adding in "i-1" to the splitpoint to get correct location slx<-c(slx[1:(thepos+(i-1))],newx,slx[(thepos+1+(i-1)):length(slx)]) sly<-c(sly[1:(thepos+(i-1))],newy,sly[(thepos+1+(i-1)):length(sly)]) } #end of for (runs) loop; all necessary points have been added } # end of if (length(runs)) modslice<-c(modslice,list(cbind(slx,sly))) names(modslice)<-c(names(modslice)[1:(length(names(modslice))-1)],paste("newsl",j,sep="")) } # end of j loop. # modslice will have one list element for each slice, empty or not mapply(function(x,y) suppressWarnings(lines(x[,1],x[,2], col=y, type='l', lty=lty,...)), modslice,cols) #suppression lets me pass '...' to both plot and lines calls, e.g. titles to plot() above if(showcuts==TRUE) { lnx<-c(min(newxx),max(newxx)) lncut<-cuts[2:(length(cuts)-1)] mapply(function(rrr,sss) lines(lnx,c(rrr,sss),lty='dotted', col='black'),lncut,lncut) } #end of showcuts IF #save interesting stuff stuff<-list(xin=x,yin=y,cuts=cuts) stuff<-c(stuff,modslice) names(stuff)<-c('xin','yin','cuts',names(modslice)) return(invisible(stuff)) } plotrix/R/clean.args.R0000755000176000001440000000112411056465626014360 0ustar ripleyusersclean.args<-function(argstr,fn,exclude.repeats=FALSE,exclude.other=NULL, dots.ok=TRUE) { fnargs<-names(formals(fn)) if(length(argstr) > 0 && !("..." %in% fnargs && dots.ok)) { badargs<-names(argstr)[!sapply(names(argstr),"%in%",c(fnargs,""))] for(i in badargs) argstr[[i]]<-NULL } if(exclude.repeats) { ntab<-table(names(argstr)) badargs<-names(ntab)[ntab > 1 & names(ntab) != ""] for (i in badargs) argstr[[i]]<-NULL } for(i in exclude.other) argstr[[i]]<-NULL argstr } remove.args<-function(argstr,fn) { fnargs <- names(formals(fn)) argstr[!(names(argstr) %in% fnargs)] } plotrix/R/centipede.plot.R0000755000176000001440000000713011717156200015250 0ustar ripleyusers# in general, get.segs expects a list with varying lengths of numeric values # it returns a 4xn matrix of midpoints, upper and lower limits and Ns # where N is the number of valid elements in the list or columns in a # data frame. get.segs<-function(x,mct="mean",lower.limit="std.error", upper.limit=lower.limit) { xlen<-length(x) segs<-matrix(0,nrow=4,ncol=xlen) for(i in 1:xlen) { segs[1,i]<-do.call(mct,list(x[[i]],na.rm=TRUE)) segs[2,i]<-segs[1,i]-do.call(lower.limit,list(x[[i]],na.rm=TRUE)) segs[3,i]<-segs[1,i]+do.call(upper.limit,list(x[[i]],na.rm=TRUE)) segs[4,i]<-sum(!is.na(x[[i]])) } rownames(segs)<-c(mct,lower.limit,upper.limit,"valid.n") colnames(segs)<-names(x) return(segs) } centipede.plot<-function(segs,mct="mean",lower.limit="std.error", upper.limit=lower.limit,left.labels=NULL,right.labels=NULL,sort.segs=TRUE, main="",xlab=NA,pch=21,vgrid=NA,hgrid=NA,gridcol="lightgray",mar=NA,col=par("fg"), bg="green",...) { if(missing(segs)) { cat("Usage: centipede.plot(segs,...)\n\twhere segs is a dstat object") stop("or a matrix of midpoints and limits") } if(is.list(segs)) { if(all(lapply(segs,is.numeric))) segs<-get.segs(segs,mct=mct,lower.limit=lower.limit, upper.limit=upper.limit) else stop("If segs is a list, all the components must be numeric") } if(class(segs) == "dstat") { midpoint<-"mean" if(lower.limit == "var") { if(rownames(segs)[2] == "var") ll<-segs[1,]-segs[2,] if(rownames(segs)[2] == "sd") ll<-segs[1,]-segs[2,]*segs[2,] } if(upper.limit == "var") { if(rownames(segs)[2] == "var") ul<-segs[1,]+segs[2,] if(rownames(segs)[2] == "sd") ul<-segs[1,]+segs[2,]*segs[2,] } if(lower.limit == "sd") { if(rownames(segs)[2] == "var") ll<-segs[1,]-sqrt(segs[2,]) if(rownames(segs)[2] == "sd") ll<-segs[1,]-segs[2,] } if(upper.limit == "sd") { if(rownames(segs)[2] == "var") ul<-segs[1,]+sqrt(segs[2,]) if(rownames(segs)[2] == "sd") ul<-segs[1,]+segs[2,] } if(lower.limit == "std.error") { if(rownames(segs)[2] == "var") ll<-segs[1,]-sqrt(segs[2,])/sqrt(segs[3,]) if(rownames(segs)[2] == "sd") ll<-segs[1,]-segs[2,]/sqrt(segs[3,]) } if(upper.limit == "std.error") { if(rownames(segs)[2] == "var") ul<-segs[1,]+sqrt(segs[2,])/sqrt(segs[3,]) if(rownames(segs)[2] == "sd") ul<-segs[1,]+segs[2,]/sqrt(segs[3,]) } segs<-rbind(segs[1,],ll,ul,segs[3,]) } segdim<-dim(segs) if (sort.segs) { seg.order<-order(segs[1,]) segs<-segs[,seg.order] } else seg.order<-1:segdim[2] oldpar<-par("mar") if(is.na(mar[1])) mar<-c(4,6,1+2*(nchar(main)>0),5) par(mar=mar) plot(x=c(min(segs[2,]),max(segs[3,])),y=c(1,segdim[2]), main=main,xlab="",ylab="",type="n",axes=FALSE,...) box() if(!is.na(vgrid[1])) abline(v=vgrid,lty=1,col=gridcol) if(is.null(hgrid)) abline(h=1:segdim[2],lty=2,col=gridcol) else if(!is.na(hgrid[1])) abline(h=hgrid,lty=2,col=gridcol) axis(1) arrows(segs[2,],1:segdim[2],segs[3,],1:segdim[2],length=0.05, angle=90,code=3,col=col) points(segs[1,],1:segdim[2],pch=pch,col=col,bg=bg) if(is.null(left.labels)) { left.labels<-colnames(segs) if(is.null(left.labels)) left.labels<-paste("V",seg.order,sep="") } else left.labels<-left.labels[seg.order] plot.limits<-par("usr") mtext(left.labels,2,line=0.2,at=1:segdim[2],adj=1,las=1) if(is.null(right.labels)) right.labels<-paste(round(segs[1,],2),"(",segs[4,],")",sep="") else right.labels<-right.labels[seg.order] mtext(right.labels,4,line=0.2,at=1:segdim[2],adj=0,las=1) if(is.na(xlab)) xlab<-paste("| -",rownames(segs)[2],"-",rownames(segs)[1],"-", rownames(segs)[3],"- |") if (nchar(xlab)) mtext(xlab,1,line = 2) par(oldpar) invisible(segs) } plotrix/R/bumpchart.R0000755000176000001440000000155312112005201014303 0ustar ripleyusersbumpchart<-function(y,top.labels=colnames(y),labels=rownames(y),rank=TRUE, mar=c(2,8,5,8),pch=19,col=par("fg"),lty=1,lwd=1,...) { if(missing(y)) stop("Usage: bumpchart(y,top.labels,labels,...)") ydim<-dim(y) if(is.null(ydim)) stop("y must be a matrix or data frame") oldmar<-par("mar") par(mar=mar) if(rank) y<-apply(y,2,rank) # to get things the right way round, reverse the order of everything labels<-rev(labels) pch=rev(pch) col=rev(col) lty=rev(lty) lwd=rev(lwd) y<-apply(y,2,rev) matplot(t(y),ylab="",type="b",pch=pch,col=col,lty=lty,lwd=lwd,axes=FALSE, ...) par(xpd=TRUE) xylim<-par("usr") minspacing<-strheight("M")*1.5 text(1:ydim[2],xylim[4],top.labels) labelpos<-spreadout(y[,1],minspacing) text(xylim[1],labelpos,labels,adj=1) labelpos<-spreadout(y[,ydim[2]],minspacing) text(xylim[2],labelpos,labels,adj=0) par(mar=oldmar,xpd=FALSE) } plotrix/R/brkdnNest.R0000755000176000001440000000527212022365537014277 0ustar ripleyusersvalid.n<-function(x,na.rm=TRUE) return(ifelse(na.rm,sum(!is.na(x)),length(x))) propbrk<-function(x,trueval=TRUE,na.rm=TRUE) { if(na.rm) return(sum(x==trueval,na.rm=TRUE)/valid.n(x)) else return(sum(x==trueval,na.rm=TRUE)/length(x)) } sumbrk<-function(x,trueval=TRUE,na.rm=TRUE) { return(sum(x==trueval,na.rm=TRUE)) } binciWu<-function(x,n,alpha=0.05,trueval=NA,na.rm=TRUE) { if(!is.na(trueval)) { n<-length(x) x<-sum(x==trueval,na.rm=TRUE) } z<-pnorm(1-alpha/2) zsq<-z*z phat<-ifelse(x<1,x,x/n) pest<-phat+zsq/(2*n) ci<-(pest+z*sqrt((phat*(1-phat))/n+zsq/(4*n*n)))/(1+zsq/n) return(ci) } binciWl<-function(x,n,alpha=0.05,trueval=NA,na.rm=TRUE) { if(!is.na(trueval)) { n<-length(x) x<-sum(x==trueval,na.rm=TRUE) } z<-pnorm(1-alpha/2) zsq<-z*z phat<-ifelse(x<1,x,x/n) pest<-phat+zsq/(2*n) ci<-(pest-z*sqrt((phat*(1-phat))/n+zsq/(4*n*n)))/(1+zsq/n) return(ci) } brkdnNest<-function(formula,data,FUN=c("mean","sd"),label1="Overall", trueval=NA) { if(missing(data) || missing(formula)) stop("brkdnNest must be called with a formula for breakdown and a data frame.") bn<-as.character(attr(terms(formula),"variables")[-1]) nbn<-length(bn) nFUN<-length(FUN) brklist<-vector("list",nFUN) for(brkfun in 1:nFUN) { brklist[[brkfun]]<-vector("list",nbn) # get the overall values if(is.na(trueval)) brklist[[brkfun]][[1]]<- do.call(FUN[brkfun],list(data[[bn[1]]],na.rm=TRUE)) else brklist[[brkfun]][[1]]<- do.call(FUN[brkfun],list(data[[bn[1]]],trueval=trueval,na.rm=TRUE)) names(brklist[[brkfun]][[1]])<-label1 for(brk in 2:nbn) { if(is.na(trueval)) brklist[[brkfun]][[brk]]<- tapply(data[[bn[1]]],data[bn[2:brk]],FUN=match.fun(FUN[brkfun]), na.rm=TRUE) else brklist[[brkfun]][[brk]]<- tapply(data[[bn[1]]],data[bn[2:brk]],FUN=match.fun(FUN[brkfun]), trueval=trueval) names(brklist[[brkfun]][[brk]])<-levels(data[[brkfun[brk]]]) } } attr(brklist,"class")<-"brklist" names(brklist)<-FUN return(brklist) } sliceArray<-function(x,slice) { dimx<-dim(x) if(is.null(dimx)) return(x[slice]) else { ndim<-length(dimx) slicestring<- paste("x[",slice,paste(rep(",",ndim-1),collapse=""),"]",sep="",collapse="") newx<-eval(parse(text=slicestring)) return(newx) } } print.brklist<-function(x,...) { crawlBreakList<-function(x,depth=1) { if(length(x)>1) { if(depth==1) cat(names(x[[1]]),unlist(x[[1]]),"\n") x[[1]]<-NULL for(nextbit in 1:length(x[[1]])) { newx<-lapply(x,sliceArray,nextbit) cat(rep("\t",depth),names(x[[1]][nextbit]),unlist(x[[1]][nextbit]),"\n") crawlBreakList(newx,depth=depth+1) } } } xnames<-names(x) for(func in 1:length(x)) { cat(xnames[func],"\n") crawlBreakList(x[[func]]) } } plotrix/R/brkdn.plot.R0000755000176000001440000001000311557744727014424 0ustar ripleyusersbrkdn.plot<-function(vars,groups=NA,obs=NA,data,mct="mean",md="std.error", stagger=NA,dispbar=TRUE,main="Breakdown plot",xlab=NA,ylab=NA,xaxlab=NA, ylim=NA,type="b",pch=1,lty=1,col=par("fg"),staxx=FALSE,...) { if(is.na(obs)) { if(is.na(groups[1])) stop("Must have at least one factor to subset data") bygroup<-as.factor(data[[groups]]) grouplevels<-levels(bygroup) ngroups<-length(grouplevels) nobs<-length(vars) obs.pos<-1:nobs obslevels<-1:nobs } else { if(is.numeric(data[[obs]])) { obs.pos<-obslevels<-sort(unique(data[[obs]])) nobs<-length(obslevels) } else { byobs<-as.factor(data[[obs]]) obslevels<-levels(byobs) nobs<-length(obslevels) obs.pos<-1:nobs } if(is.na(groups)) { ngroups<-length(vars) grouplevels<-1:ngroups } else { bygroup<-as.factor(data[[groups]]) grouplevels<-levels(bygroup) ngroups<-length(grouplevels) if(length(vars) > 1) { warning("Group and observation factors are present, only vars[1] is plotted") vars<-vars[1] } } } brkdn<-list(matrix(NA,nrow=ngroups,ncol=nobs), matrix(NA,nrow=ngroups,ncol=nobs)) if(is.na(groups)) { if(is.na(xlab)) xlab<-"Observation" xat<-1:nobs if(is.na(xaxlab[1])) xaxlab<-obslevels for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-data[[vars[group]]][data[[obs]] == obslevels[ob]] if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group,ob]<-thisbit } } } } else { if(is.na(obs)) { if(is.na(xlab)) xlab<-"Variable" xat<-1:length(vars) if(is.na(xaxlab[1])) xaxlab<-vars for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-data[[vars[ob]]][data[[groups]] == grouplevels[group]] if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group,ob]<-thisbit } } } } else { if(is.na(xlab)) xlab<-"Observation" xat<-obs.pos if(is.na(xaxlab[1])) xaxlab<-obslevels for(group in 1:ngroups) { for(ob in 1:nobs) { thisbit<-data[[vars]][data[[groups]] == grouplevels[group] & data[[obs]] == obslevels[ob]] if(length(thisbit)) { if(length(thisbit) > 1) { brkdn[[1]][group,ob]<-do.call(mct,list(thisbit,na.rm=TRUE)) if(!is.na(md)) brkdn[[2]][group,ob]<-do.call(md,list(thisbit,na.rm=TRUE)) } else brkdn[[1]][group,ob]<-thisbit } } } } } if(is.na(ylim[1])) { ylim<-range(brkdn[[1]],na.rm=TRUE) if(!is.na(md)) { dlim<-c(min(brkdn[[1]]-brkdn[[2]],na.rm=TRUE), max(brkdn[[1]]+brkdn[[2]],na.rm=TRUE)) ylim<-c(min(c(ylim[1],dlim[1])),max(c(ylim[2],dlim[2]))) } } groupdiv<-ifelse(ngroups < 3,1,ngroups-2) if(is.na(stagger)) stagger<-0.025-groupdiv*0.0025 if(is.na(ylab)) { if(length(vars) == 1) ylab<-vars[1] else ylab<-paste(vars,collapse=" and ") } plot(0,xlim=c(obs.pos[1]-0.5,obs.pos[nobs]+0.5),main=main, xlab=xlab,ylab=ylab,ylim=ylim,type="n",axes=FALSE,...) box() if(staxx) staxlab(at=xat,labels=xaxlab) else axis(1,at=xat,labels=xaxlab) axis(2) if(length(pch) < ngroups) pch<-rep(pch,length.out=ngroups) if(length(col) < ngroups) col<-rep(col,length.out=ngroups) if(length(lty) < ngroups) lty<-rep(lty,length.out=ngroups) offinc<-stagger*diff(par("usr")[c(1,2)]) offset<-0 arrow.cap<-0.01-(groupdiv*0.001) for(group in 1:ngroups) { points(obs.pos+offset,brkdn[[1]][group,],type=type,col=col[group], pch=pch[group],lty=lty[group]) if(dispbar) dispersion(obs.pos+offset,brkdn[[1]][group,],brkdn[[2]][group,], arrow.cap=arrow.cap,col=col[group]) offset<-ifelse(offset<0,-offset,-offset-offinc) } names(brkdn)<-c(mct,md) return(brkdn) } plotrix/R/boxed.labels.R0000755000176000001440000000215511561464415014706 0ustar ripleyusersboxed.labels<-function(x,y=NA,labels, bg=ifelse(match(par("bg"),"transparent",0),"white",par("bg")), border=TRUE,xpad=1.2,ypad=1.2,srt=0,cex=1,adj=0.5,...) { oldcex<-par("cex") par(cex=cex) if(is.na(y) && is.list(x)) { y<-unlist(x[[2]]) x<-unlist(x[[1]]) } box.adj<-adj+(xpad-1)*cex*(0.5-adj) # boxes can only be rotated 90 degrees either way if(srt==90 || srt==270) { bheights<-strwidth(labels) theights<-bheights*(1-box.adj) bheights<-bheights*box.adj lwidths<-rwidths<-strheight(labels)*0.5 } else { lwidths<-strwidth(labels) rwidths<-lwidths*(1-box.adj) lwidths<-lwidths*box.adj bheights<-theights<-strheight(labels)*0.5 } # fix for adding a col argument to ... by Thorn Thaler args <- list(x = x, y = y, labels = labels, srt = srt, adj = adj, col = ifelse(colSums(col2rgb(bg) * c(1, 1.4, 0.6)) < 350, "white", "black")) args <- modifyList(args, list(...)) rect(x - lwidths * xpad, y - bheights * ypad, x + rwidths * xpad, y + theights * ypad, col = bg, border = border) do.call(text, args) par(cex=oldcex) } plotrix/R/box.heresy.R0000644000176000001440000000155411773557567014451 0ustar ripleyusersbox.heresy<-function(x,y,uinner,linner=uinner,ulim,llim=ulim,intervals=FALSE, arrow.cap=NA,pch=22,main="",xlab="",ylab="",xaxlab=NA,col="white", do.first=NULL,...) { if(missing(y)) { y<-x x<-1:length(y) } if(is.na(xaxlab)) xaxlab<-x if(intervals) { ulim<-y+ulim llim<-y-llim } if(length(x) > 1) xrange<-range(x) else xrange<-c(0.5,1.5) xspace<-diff(xrange)/10 boxwidth<-diff(xrange)/(4*length(x)) plot(x,y,xlim=c(xrange[1]-xspace,xrange[2]+xspace),ylim=range(c(llim,ulim)), main=main,xlab=xlab,ylab=ylab,type="n",xaxt="n") if(!is.null(do.first)) eval(do.first) axis(1,at=x,labels=xaxlab) if(is.na(arrow.cap)) arrow.cap<-boxwidth/diff(par("usr")[1:2]) dispersion(x,y,ulim,llim,intervals=FALSE,arrow.cap=arrow.cap,...) if(intervals) { uinner<-y+uinner linner<-y-linner } rect(x-boxwidth,linner,x+boxwidth,uinner,col=col) points(x,y,pch=pch) } plotrix/R/battleship.plot.R0000644000176000001440000000201012112004513015421 0ustar ripleyusersbattleship.plot<-function(x,mar=c(2,5,5,1),col="white",border="black", main="",xlab="",ylab="",xaxlab=NA,yaxlab=NA,cex.labels=1, maxxspan=0.45,maxyspan=0.45) { dimx<-dim(x) if(length(dimx) != 2) stop("battleship.plot(x) where x is a 2 dimensional matrix or data frame") par(mar=mar) plot(0,xlim=c(0.5,dimx[2]+0.5),ylim=c(0.5,dimx[1]+0.5),axes=FALSE, type="n",xlab="",ylab="") title(main=main,line=mar[3]-2) mtext(xlab,side=1,line=0) if(is.na(xaxlab[1])) { xaxlab<-colnames(x) if(is.null(xaxlab)) xaxlab<-1:dimx[2] } staxlab(side=3,at=1:dimx[2],labels=xaxlab,srt=45,adj=0,top.line=0, ticklen=0,cex=cex.labels) if(is.na(yaxlab[1])) { yaxlab<-rownames(x) if(is.null(yaxlab)) yaxlab<-1:dimx[1] } staxlab(side=2,at=dimx[1]:1,labels=yaxlab,nlines=1,srt=0,adj=1, top.line=0,ticklen=0,cex=cex.labels) normx<-maxxspan*x/max(x,na.rm=TRUE) rect(rep(1:dimx[2],each=dimx[1])-normx,rep(dimx[1]:1,dimx[2])-maxyspan, rep(1:dimx[2],each=dimx[1])+normx,rep(dimx[1]:1,dimx[2])+maxyspan, col=col,border=border) } plotrix/R/barp.R0000755000176000001440000001102711760354360013264 0ustar ripleyusersbarp<-function(height,width=0.4,names.arg=NULL,legend.lab=NULL,legend.pos=NULL, col=NULL,border=par("fg"),main=NULL,xlab="",ylab="",xlim=NULL,ylim=NULL,x=NULL, staxx=FALSE,staxy=FALSE,height.at=NULL,height.lab=NULL,cex.axis=par("cex.axis"), pch=NULL,cylindrical=FALSE,shadow=FALSE,do.first=NULL,ylog=FALSE,srt=NA) { height.class<-attr(height,"class") if(!is.null(height.class)) { if(match(height.class,"dstat",0)) { md1<-length(height) md2<-dim(height[[1]])[2] meanmat<-matrix(NA,nrow=md1,ncol=md2) colnames(meanmat)<-colnames(height[[1]]) for(row in 1:md1) meanmat[row,]<-height[[row]][1,] height<-meanmat } if(match(height.class,"freq",0)) height<-height[[1]] } if(is.data.frame(height)) its_ok<-is.numeric(unlist(height)) else its_ok<-is.numeric(height) if(!its_ok) stop("barp can only display bars with numeric heights") hdim<-dim(height) if(is.null(x)) x<-1:length(height) if(is.null(hdim) || length(hdim) == 1) { ngroups<-length(height) barcol<-col barpinfo<-list(x=x,y=height) hdim<-NULL } else { ngroups<-hdim[2] x<-1:ngroups if(!is.matrix(col) && length(col)==hdim[1]) barcol<-matrix(rep(col,each=ngroups),nrow=hdim[1],byrow=TRUE) else barcol<-col if(!is.matrix(pch) && length(pch)==hdim[1]) pch<-matrix(rep(pch,ngroups),nrow=hdim[1]) barpinfo<-list(x=matrix(rep(1:ngroups,each=hdim[1]),ncol=hdim[2]), y=as.matrix(height)) } if(is.null(xlim)) xlim<-range(x)+c(-0.6,0.6) negy<-any(height<0,na.rm=TRUE) if(is.null(ylim)) { if(negy) miny<-min(height,na.rm=TRUE)*1.05 else miny<-ifelse(ylog,min(height)/10,0) ylim<-c(miny,max(height,na.rm=TRUE)*1.05) } else miny<-ylim[1] plot(ylim[1],type="n",main=main,xlab=xlab,ylab=ylab,axes=FALSE,xlim=xlim, ylim=ylim,xaxs="i",yaxs="i",log=ifelse(ylog,"y","")) if(!is.null(do.first)) eval(do.first) if(negy) abline(h=0) if(is.null(names.arg)) names.arg<-x if(staxx) { axis(1,at=x,labels=rep("",ngroups),cex.axis=cex.axis) staxlab(1,at=x,labels=names.arg,cex=cex.axis,srt=srt) } else axis(1,at=x,labels=names.arg,cex.axis=cex.axis) if(is.null(height.at)) { if(ylog) height.at<-axTicks(2,log=TRUE) else height.at<-pretty(ylim) if(max(height.at) > max(height,na.rm=TRUE)) height.at<-height.at[-length(height.at)] } if(is.null(height.lab)) height.lab<-height.at if(staxy) { axis(2,at=height.at,labels=rep("",length(height.lab)),cex.axis=cex.axis) staxlab(2,at=height.at,labels=height.lab,cex=cex.axis,srt=srt) } else axis(2,at=height.at,labels=height.lab,cex.axis=cex.axis) bottoms<-ifelse(negy,0,miny) if(is.null(hdim)) { if(shadow) { for(bar in 1:ngroups) polygon.shadow(c(x[bar]-width,x[bar]-width,x[bar]+width,x[bar]+width), c(bottoms,height[bar],height[bar],bottoms), offset=c(0.2*width,0.05*(height[bar]-ylim[2]))) } if(cylindrical) cylindrect(x-width,bottoms,x+width,height,col=barcol, border=border) else { if(is.null(pch)) rect(x-width,bottoms,x+width,height,col=barcol,border=border) else rectFill(x-width,bottoms,x+width,height,bg="white",fg="black", pch=pch) } } else { bottoms<-matrix(bottoms,nrow=hdim[1],ncol=hdim[2]) barwidth<-2*width/hdim[1] for(subgroup in 1:hdim[1]) { barpinfo$x[subgroup,]<-1:ngroups-width+(subgroup-0.5)*barwidth if(shadow) { for(bar in 1:ngroups) { barleft<-bar-width+(subgroup-1)*2*width/hdim[1] barright<-barleft+2*width/hdim[1] polygon.shadow(c(barleft,barleft,barright,barright), c(bottoms[bar],height[subgroup,bar],height[subgroup,bar],bottoms[bar]), offset=c(0.2*width,0.05*(height[subgroup,bar]-ylim[2]))) } } if(cylindrical) cylindrect(1:ngroups-width+(subgroup-1)*barwidth,bottoms[subgroup,], 1:ngroups-width+(subgroup)*barwidth,height[subgroup,], col=barcol[subgroup,],border=border) else { if(is.null(pch)) rect(1:ngroups-width+(subgroup-1)*barwidth,bottoms[subgroup,], 1:ngroups-width+(subgroup)*barwidth,height[subgroup,], col=barcol[subgroup,],border=border) else rectFill(1:ngroups-width+(subgroup-1)*barwidth,bottoms[subgroup,], 1:ngroups-width+(subgroup)*barwidth,height[subgroup,], bg="white",fg="black",pch=pch[subgroup,]) } } } if(!is.null(legend.lab)) { xjust<-yjust<-0.5 if(is.null(legend.pos)) { cat("Click at the lower left corner of the legend\n") legend.pos<-locator(1) xjust<-yjust<-0 } legend(legend.pos,legend=legend.lab,fill=col,xjust=xjust,yjust=yjust) } box() invisible(barpinfo) } plotrix/R/barlabels.R0000644000176000001440000000150211771036471014263 0ustar ripleyusersbarlabels<-function(xpos,ypos,labels=NULL,cex=1,prop=0.5,miny=0,offset=0,...) { if(is.data.frame(ypos)) ypos<-as.matrix(ypos) if(is.null(labels)) labels<-ypos # usually don't want to display zero labels display<-ypos > miny if(is.matrix(ypos)) { # prop is within the scope of the current environment cumcenter<-function(x,pos) return(cumsum(x)-x*prop) stacked<-length(xpos) < length(ypos) if(stacked) { # replicate the x positions one by one, but the offsets group by group xpos<-rep(xpos,each=length(ypos)/length(xpos))+ rep(c(-offset,offset),length(ypos)/(2*length(xpos))) ypos<-apply(ypos,2,cumcenter) } else ypos<-ypos*prop } else ypos<-ypos*prop # allow labels to extend beyond the plot area par(xpd=TRUE) boxed.labels(xpos[display],ypos[display],labels[display],cex=cex,...) par(xpd=FALSE) } plotrix/R/barNest.R0000755000176000001440000000515412110256634013735 0ustar ripleyusersbarNest<-function(formula=NULL,data=NULL,FUN=c("mean","sd"), ylim=NULL,main="",xlab="",ylab="",shrink=0.1,errbars=FALSE, col=NA,labelcex=1,lineht=NA,showall=TRUE,barlabels=NULL, showlabels=TRUE,mar=NULL,arrow.cap=NA,trueval=NA) { x<-brkdnNest(formula=formula,data=data,FUN=FUN,trueval=trueval) getBreakListNames<-function(x) { blnames<-list(names(x[[1]][[1]])) for(level in 2:length(x[[1]])) blnames[[level]]<-dimnames(x[[1]][[level]])[[level-1]] return(blnames) } if(is.null(barlabels)) barlabels<-getBreakListNames(x) nbn<-length(as.character(attr(terms(formula),"variables")[-1])) # don't use overall value to calculate ylim when counts are displayed # or when the "sum" function is used to combine pre-calculated values if(FUN[1]=="valid.n" || FUN[1]=="sumbrk" || FUN[1]=="sum") { if(is.null(ylim)) ylim<-c(0,1.04*max(unlist(x[[1]][[2]]),na.rm=TRUE)) if(FUN[1]=="valid.n" || FUN[1]=="sum") barlabels[[1]]<-"" } else { lenx<-length(x) if(errbars) { errbars<-length(x) if(lenx == 3) { # x[[2]] is the higher dispersion limit, x[[3]] is the lower if(is.null(ylim)) ylim<-c(min(unlist(x[[3]]),na.rm=TRUE), max(unlist(x[[2]]),na.rm=TRUE)) } else { # x[[2]] is a symmetric dispersion interval, get the limits x[[3]]<-x[[2]] if(is.null(ylim)) ylim<-c(min(unlist(x[[1]])-unlist(x[[3]]),na.rm=TRUE), max(unlist(x[[1]])+unlist(x[[2]]),na.rm=TRUE)) # bottom of plot must be at zero if(ylim[1] < 0) ylim[1]<-0 } if(is.na(arrow.cap)) arrow.cap<-0.25/length(unlist(x[[1]])) } else { # funname<-names(x[[1]][[1]])[2] if(is.null(ylim)) ylim<-range(unlist(x[[1]]),na.rm=TRUE) } # add the bit of space at the top ylim<-ylim+c(ifelse(ylim[1]<0,-0.04,0),0.04)*diff(ylim) # don't display negative values if(ylim[1] > 0) ylim[1]<-0 } if(!is.null(mar)) oldmar<-par(mar=mar) # display the blank plot plot(0,xlim=c(0,1),ylim=ylim,main=main,xlab=xlab, ylab=ylab,xaxt="n",yaxs="i",type="n") # get the plot limits parusr<-par("usr") # if no line height specified for the labels, calculate it if(is.na(lineht)) lineht<-1.05*labelcex*diff(parusr[3:4])* (par("mai")[1]/par("pin")[2])/par("mar")[1] # number of levels to plot nlevels=length(x[[1]]) drawNestedBars(x,start=0,end=1,shrink=shrink,errbars=errbars, col=col,labelcex=labelcex,lineht=lineht,showall=showall, barlabels=barlabels,showlabels=showlabels,arrow.cap=arrow.cap) # is this needed? abline(h=0) if(FUN[1]=="valid.n") box() # if the margins were changed, reset them if(!is.null(mar)) par(mar=oldmar) invisible(x) } plotrix/R/axis.mult.R0000755000176000001440000000210711056465626014271 0ustar ripleyusersaxis.mult<-function(side=1,at=NULL,labels,mult=1,mult.label,mult.line, mult.labelpos=NULL,...) { if(is.null(at)) at<-axTicks(side) if(missing(labels)) labels<-at/mult axis(side,at,labels,...) if(missing(mult.label)) mult.label<-paste("x",mult,collapse="") # multiplier position defaults to centered on the outside if(is.null(mult.labelpos)) mult.labelpos<-side edges<-par("usr") if(side %% 2) { # either top or bottom if(mult.labelpos %% 2) { adj<-0.5 at<-(edges[1]+edges[2])/2 if(missing(mult.line)) mult.line<-ifelse(mult.labelpos == side,3,0) } else { adj<-ifelse(mult.labelpos == 2,1,0) at<-ifelse(mult.labelpos == 2,edges[1],edges[2]) if(missing(mult.line)) mult.line<-1 } } else { # either left or right if(mult.labelpos %% 2) { adj<-ifelse(mult.labelpos == 1,1,0) at<-ifelse(mult.labelpos == 1,edges[3],edges[4]) if(missing(mult.line)) mult.line<-1 } else { adj<-0.5 at<-(edges[3]+edges[4])/2 if(missing(mult.line)) mult.line=ifelse(mult.labelpos == side,3,0) } } mtext(mult.label,side,mult.line,at=at,adj=adj,...) } plotrix/R/axis.break.R0000755000176000001440000000712211405142162014357 0ustar ripleyusers# axis.break places a break marker at the position "breakpos" # in user coordinates on the axis nominated - see axis(). axis.break<-function(axis=1,breakpos=NULL,pos=NA,bgcol="white",breakcol="black", style="slash",brw=0.02) { # get the coordinates of the outside of the plot figxy<-par("usr") # flag if either axis is logarithmic xaxl<-par("xlog") yaxl<-par("ylog") # calculate the x and y offsets for the break xw<-(figxy[2]-figxy[1])*brw yw<-(figxy[4]-figxy[3])*brw if(!is.na(pos)) figxy<-rep(pos,4) # if no break position was given, put it just off the plot origin if(is.null(breakpos)) breakpos<-ifelse(axis%%2,figxy[1]+xw*2,figxy[3]+yw*2) if(xaxl && (axis == 1 || axis == 3)) breakpos<-log10(breakpos) if(yaxl && (axis == 2 || axis == 4)) breakpos<-log10(breakpos) # set up the "blank" rectangle (left, bottom, right, top) switch(axis, br<-c(breakpos-xw/2,figxy[3]-yw/2,breakpos+xw/2,figxy[3]+yw/2), br<-c(figxy[1]-xw/2,breakpos-yw/2,figxy[1]+xw/2,breakpos+yw/2), br<-c(breakpos-xw/2,figxy[4]-yw/2,breakpos+xw/2,figxy[4]+yw/2), br<-c(figxy[2]-xw/2,breakpos-yw/2,figxy[2]+xw/2,breakpos+yw/2), stop("Improper axis specification.")) # get the current setting of xpd old.xpd<-par("xpd") # don't cut the break off at the edge of the plot par(xpd=TRUE) # correct for logarithmic axes if(xaxl) br[c(1,3)]<-10^br[c(1,3)] if(yaxl) br[c(2,4)]<-10^br[c(2,4)] if(style == "gap") { if(xaxl) { figxy[1]<-10^figxy[1] figxy[2]<-10^figxy[2] } if(yaxl) { figxy[3]<-10^figxy[3] figxy[4]<-10^figxy[4] } # blank out the gap area and calculate the line segments if(axis == 1 || axis == 3) { rect(breakpos,figxy[3],breakpos+xw,figxy[4],col=bgcol,border=bgcol) xbegin<-c(breakpos,breakpos+xw) ybegin<-c(figxy[3],figxy[3]) xend<-c(breakpos,breakpos+xw) yend<-c(figxy[4],figxy[4]) if(xaxl) { xbegin<-10^xbegin xend<-10^xend } } else { rect(figxy[1],breakpos,figxy[2],breakpos+yw,col=bgcol,border=bgcol) xbegin<-c(figxy[1],figxy[1]) ybegin<-c(breakpos,breakpos+yw) xend<-c(figxy[2],figxy[2]) yend<-c(breakpos,breakpos+yw) if(xaxl) { xbegin<-10^xbegin xend<-10^xend } } # clip the lines par(xpd=TRUE) } else { # draw the "blank" rectangle rect(br[1],br[2],br[3],br[4],col=bgcol,border=bgcol) if(style == "slash") { # calculate the slash ends if(axis == 1 || axis == 3) { xbegin<-c(breakpos-xw,breakpos) xend<-c(breakpos,breakpos+xw) ybegin<-c(br[2],br[2]) yend<-c(br[4],br[4]) if(xaxl) { xbegin<-10^xbegin xend<-10^xend } } else { xbegin<-c(br[1],br[1]) xend<-c(br[3],br[3]) ybegin<-c(breakpos-yw,breakpos) yend<-c(breakpos,breakpos+yw) if(yaxl) { ybegin<-10^ybegin yend<-10^yend } } } else { # calculate the zigzag ends if(axis == 1 || axis == 3) { xbegin<-c(breakpos-xw/2,breakpos-xw/4,breakpos+xw/4) xend<-c(breakpos-xw/4,breakpos+xw/4,breakpos+xw/2) ybegin<-c(ifelse(yaxl,10^figxy[3+(axis==3)],figxy[3+(axis==3)]),br[4],br[2]) yend<-c(br[4],br[2],ifelse(yaxl,10^figxy[3+(axis==3)],figxy[3+(axis==3)])) if(xaxl) { xbegin<-10^xbegin xend<-10^xend } } else { xbegin<-c(ifelse(xaxl,10^figxy[1+(axis==4)],figxy[1+(axis==4)]),br[1],br[3]) xend<-c(br[1],br[3],ifelse(xaxl,10^figxy[1+(axis==4)],figxy[1+(axis==4)])) ybegin<-c(breakpos-yw/2,breakpos-yw/4,breakpos+yw/4) yend<-c(breakpos-yw/4,breakpos+yw/4,breakpos+yw/2) if(yaxl) { ybegin<-10^ybegin yend<-10^yend } } } } # draw the segments segments(xbegin,ybegin,xend,yend,col=breakcol,lty=1) # restore xpd par(xpd=FALSE) } plotrix/R/arctext.R0000755000176000001440000000233112026032306013775 0ustar ripleyusersarctext<-function(x,center=c(0,0),radius=1,start=NA,middle=pi/2,end=NA,stretch=1, clockwise=TRUE,cex=NA, ...) { oldcex <- par("cex") # have to do this to get strwidth to work if(is.na(cex)) cex <- oldcex par(cex=cex) xvec <- strsplit(x, "")[[1]] lenx <- length(xvec) xwidths <- stretch * strwidth(xvec) charangles <- xwidths/radius changrang <- range(charangles) # Make really narrow characters wider charangles[charangles < changrang[2]/2] <- changrang[2]/2 if (!is.na(end)) start <- end + sum(charangles) if (is.na(start)) { if(clockwise) start <- middle + sum(charangles)/2 else start <- middle - sum(charangles)/2 } if(clockwise) { charstart <- c(start, start - cumsum(charangles)[-lenx]) charpos <- charstart - charangles/2 } else { charstart <- c(start, start + cumsum(charangles)[-lenx]) charpos <- charstart + charangles/2 } xylim <- par("usr") plotdim <- par("pin") ymult <- (xylim[4] - xylim[3])/(xylim[2] - xylim[1]) * plotdim[1]/plotdim[2] for (xchar in 1:lenx) { srt <- 180 * charpos[xchar]/pi - 90 text(center[1] + radius * cos(charpos[xchar]), center[2] + radius * sin(charpos[xchar]) * ymult,xvec[xchar], adj=c(0.5, 0.5),srt=srt + 180 * !clockwise, ...) } par(cex=oldcex) } plotrix/R/addtable2plot.R0000755000176000001440000000636212115331056015057 0ustar ripleyusersaddtable2plot<-function(x,y=NULL,table,lwd=par("lwd"),bty="n", bg=par("bg"),cex=1,xjust=0,yjust=1,xpad=0.1,ypad=0.5,box.col=par("fg"), text.col=par("fg"),display.colnames=TRUE,display.rownames=FALSE, hlines=FALSE,vlines=FALSE,title=NULL) { # make sure that there is a graphics device open if(dev.cur() == 1) stop("Cannot add table unless a graphics device is open") # check for an xy.coords structure if(is.null(y)) { if(is.null(x$y)) stop("both x and y coordinates must be given") y<-x$y x<-x$x } tabdim<-dim(table) if(is.null(dim(bg))) bg<-matrix(bg,nrow=tabdim[1],ncol=tabdim[2]) column.names<-colnames(table) if(is.null(column.names) && display.colnames) column.names<-1:tabdim[2] row.names<-rownames(table) if(is.null(row.names) && display.rownames) row.names<-1:tabdim[1] if(par("xlog")) x<-log10(x) cellwidth<-rep(0,tabdim[2]) # assume that the column names will be at least as wide as the entries if(display.colnames) { for(column in 1:tabdim[2]) cellwidth[column]<-max(strwidth(c(column.names[column], format(table[,column])),cex=cex))*(1+xpad) nvcells<-tabdim[1]+1 } else { nvcells<-tabdim[1] for(column in 1:tabdim[2]) cellwidth[column]<-max(strwidth(format(table[,column]),cex=cex))*(1+xpad) } if(display.rownames) { nhcells<-tabdim[2]+1 rowname.width<-max(strwidth(row.names,cex=cex))*(1+xpad) } else { nhcells<-tabdim[2] rowname.width<-0 } if(par("ylog")) y<-log10(y) cellheight<- max(strheight(c(column.names,row.names,as.vector(unlist(table))), cex=cex))*(1+ypad) ytop<-y+yjust*nvcells*cellheight # adjust for logarithmic plotting and allow the table to extend beyond the plot oldpar<-par(xlog=FALSE,ylog=FALSE,xpd=TRUE) if(display.colnames) { xleft<-x+display.rownames*rowname.width for(column in 1:tabdim[2]) { text(xleft+cellwidth[column]*0.5, ytop-0.5*cellheight,column.names[column],cex=cex,col=text.col) xleft<-xleft+cellwidth[column] } } for(row in 1:tabdim[1]) { # start at the left edge of the table xleft<-x if(display.rownames) { text(xleft+0.5*rowname.width, ytop-(row+display.colnames-0.5)*cellheight, row.names[row],cex=cex,col=text.col) xleft<-xleft+rowname.width } for(column in 1:tabdim[2]) { text(xleft+0.5*cellwidth[column], ytop-(row+display.colnames-0.5)*cellheight, table[row,column],cex=cex,col=text.col) xleft<-xleft+cellwidth[column] } } if(vlines) { xleft<-x+display.rownames*rowname.width segments(xleft+cumsum(cellwidth[-tabdim[2]]), ytop-display.colnames*cellheight, xleft+cumsum(cellwidth[-tabdim[2]]), ytop-(display.colnames+tabdim[1])*cellheight) } if(hlines) { xleft<-x+display.rownames*rowname.width segments(xleft, ytop-display.colnames*cellheight-cumsum(rep(cellheight,tabdim[1]-1)), xleft+sum(cellwidth), ytop-display.colnames*cellheight-cumsum(rep(cellheight,tabdim[1]-1))) } if(bty == "n") rect(xleft,ytop-nvcells*cellheight,xleft+sum(cellwidth), ytop-cellheight*display.colnames,lwd=lwd,border=box.col) if(!is.null(title)) { xleft<-x-xjust*(sum(cellwidth)+rowname.width) text(xleft+(rowname.width+sum(cellwidth))/2,ytop+cellheight/2,title, cex=cex,col=text.col) } par(oldpar) } plotrix/R/add.ps.R0000744000176000001440000000340311747474157013522 0ustar ripleyusersadd.ps <- function(data, col.id, col.offset, col.x, col.value, fun.aggregate = "mean", ref.offset = 1, prefixes, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, lty = 0, ... ) { round.ps <- function(x) { as.character(ifelse(x < 0.001, "<.001", ifelse(x < 0.01, paste("=", substr(round(x, 3),2,5), sep =""),ifelse((x < 0.05) & (round(x, 2) == 0.05), "<.05", ifelse(round(x,2) == 1, ">.99", paste("=", substr(round(x, 2), 2, 4), sep = "")))))) } if(!is.data.frame(data)) stop("data must be a data.frame") columns <- c(col.id, col.offset, col.x, col.value) if (any(!(columns %in% colnames(data)))) stop("column not matching the data") formula.agg <- as.formula(paste(col.value, "~", col.id, "+", col.offset, "+", col.x)) d.new <- aggregate(formula.agg, data = data, FUN = fun.aggregate) #so far same as in rm.plot2 l.offset <- levels(factor(d.new[,col.offset])) l.offset.test <- l.offset[-ref.offset] if (missing(prefixes)) prefixes <- paste("p(", l.offset.test, ")", sep = "") l.x <- levels(factor(d.new[,col.x])) for (c.offset in seq_along(l.offset.test)) { tmp.ps <- vector("numeric", length(l.x)) for (c.x in seq_along(l.x)) { tmpx <- d.new[d.new[,col.offset] == l.offset[ref.offset] & d.new[,col.x] == l.x[c.x], ] tmpx <- tmpx[order(tmpx[,col.id]),] tmpy <- d.new[d.new[,col.offset] == l.offset.test[c.offset] & d.new[,col.x] == l.x[c.x], ] tmpy <- tmpy[order(tmpy[,col.id]),] tmp.ps[c.x] <- t.test(tmpx[,col.value], tmpy[,col.value], alternative = alternative, mu = mu, paired = paired, var.equal = var.equal)$p.value } tmp.labels <- paste(prefixes[c.offset], round.ps(tmp.ps), sep = "") axis(1,seq_along(l.x), labels = tmp.labels, line = c.offset, lty = lty, ...) } } plotrix/R/ablineclip.R0000755000176000001440000000107711670357040014444 0ustar ripleyusersablineclip<-function(a=NULL,b=NULL,h=NULL,v=NULL,reg=NULL, coef=NULL,untf=FALSE,x1=NULL,x2=NULL,y1=NULL,y2=NULL,...) { if(!is.null(c(x1,x2,y1,y2))) { oldclip<-par("usr") # if any clipping perimeters are not supplied, use the existing plot edges if(is.null(x1)) x1<-oldclip[1] if(is.null(x2)) x2<-oldclip[2] if(is.null(y1)) y1<-oldclip[3] if(is.null(y2)) y2<-oldclip[4] clip(x1,x2,y1,y2) abline(h=oldclip[4]+1) clip(x1,x2,y1,y2) } abline(a=a,b=b,h=h,v=v,reg=reg,coef=coef,untf=untf,...) if(!is.null(c(x1,x2,y1,y2))) do.call("clip",as.list(oldclip)) } plotrix/NEWS0000755000176000001440000002366112132121214012502 0ustar ripleyusersversion 3.5 fixed the "priorities extremes" bug in gantt.chart (thanks to Michael Motta) pyramid.plot now accepts NA values (thanks to Susumu Tanimura) radial.plot now does a rank clock plot (thanks to Don Dennerline) version 3.4-7 added automatic spreading out to pie.labels version 3.4-6 fixed the kite line positioning in kiteChart (thanks to Justin Dellinger) version 3.4-5 fixed the upside down character bug in arctext fixed the typo in the demo function for kite chart version 3.4-4 added the radial.grid function to the NAMESPACE version 3.4-3 minor bug that counted NAs in the propbrk function fixed version 3.4-2 Character spacing and placement improved in draw.arc and arctext (thanks to Ted Toal) radialtext and draw.radial.line functions added (also thanks to Ted Toal) weighted.hist now allows a custom X axis to be displayed (thanks to Ben Graf) Added the barlabels function version 3.4-1 Fixed the alignment problem in pie3D and rationalized angle increments Added the raw.means.plot functions contributed by Henrik Singmann vastly improved the speed of the sizetree function added the "varpos" argument to the kiteChart function - thanks to Nikolaus Lampardariou) version 3.4 added the border argument to the sizetree function multhist now returns all values from hist - thanks to John Muccigrosso fixed a bug in addtable2plot that appeared on plots with a log x axis fixed an almost invisible bug in drawSectorAnnulus - thanks to Denes added the "mar" argument to pie3D - thanks to Qinghua Zhao version 3.3-9 Fixed the bug in centipede.plot that I introduced in v3.3-8 version 3.3-8 added the horizontal grid argument to centipede plot (thanks to Colin Wahl) version 3.3-7 Fixed a color bug in plotCI (thanks to Daniel Wollschlaeger) version 3.3-6 Added the battleship plot (or Ford curve) thanks to Adam Maltese Added the box.heresy function - thanks to Gianni Lavaredo version 3.3-4 Added the display.na argument to the dispersion function (thanks to Lasse Jacobsen) Removed the "Overall" bar in barNest when counts are being displayed version 3.3-3 Fixed a bug in the Hinton diagram option (thanks to Xavier Fernández i Marín) version 3.3-2 color2D.matplot will now display a Hinton diagram added padding for negative values in twoord.plot (thanks to Hans Borcher) added the maxEmptyRect function (thanks again to Hans Borchers) version 3.3-1 expanded the color options and added top labels in sizetree returned the frequency calculation in weighted.hist to what it used to be version 3.3 fixed the vertical lines color in addtable2plot fixed the frequency calculation in weighted.hist (thanks to Jarad Niemi) added the size_n_color plot version 3.2-8 added partitioning of intersections to intersectDiagram version 3.2-7 bug fix for the examples in ladderplot version 3.2-6 added the ruginv function after fixing some encoding problems version 3.2-5 fixed a color assignment problem in plotCI added automatic color assignment in sizetree where all levels use the same colors version 3.2-4 Fixed the missing "shade" argument in pie3D (thanks to Jesse Brown) Added specifiable priority legend label and extreme descriptors (thanks to Pedro Reis) Added the (experimental) radial.pie function version 3.2-3 Fixed a few warnings from CRAN check (dotplot.mtb, gap.boxplot, symbolbarplot) Added the ruginv function (thanks to Peter Solymos) version 3.2-2 Added the labbePlot function (thanks to Whitney Melroy) Fixed the showall argument problem in the barNest function Fixed the problem with data frame input in the intersectDiagram function version 3.2-1 Added the sumbrk function to brkdnNest (thanks to Kevin Burnham) The dispbars function (just a call to dispersion) is now gone Added user specified text colors to boxed.labels (thanks to Thorn Thaler) Added the ehplot function (thanks to Robby, Michael & Felix) version 3.2 Rewrote intersectDiagram to use equidistant spacing Fixed a warning in oz.windrose.legend Fixed default ordinate scaling in twoord.plot Major rewrite of brkdnNest, barNest and drawNestedBars functions Major rewrite of color.scale function Added sliceArray function for barNest due to the above rewrite version 3.1-2 Fixed a minor bug in intersectDiagram version 3.1-1 Border colors added to gantt.chart (thanks to Brandon Fessler) Extensive rewrite of the intersectDiagram function and helpers Rewrite of the dendroPlot function categoryReshape function added version 3.1 intersectDiagram zero instance levels fixed intersectDiagram now invisibly returns the list of intersections Spacing within levels in intersectDiagram simplified makeIntersectList now discards empty levels of intersection makeIntersectList color assignment fixed dendroPlot function added version 3.0-9 Fixed the priority coloring problem in gantt.chart Added optional vertical lines to addtable2plot (thanks to Bill Sperry) Fixed the overshooting y axis for certain values of y in barp version 3.0-8 Added semi-intelligent cell labelling to the color2D.matplot function version 3.0-7 Fixed the right ordinate alignment in twoord.plot version 3.0-6 Added the "barlabels" argument to drawNestedBars big fix for the makeDendrite, furc and plot.dendrite functions version 3.0-5 added Christophe Dutang's fix for the twoord.stackpoly function fixed the confidence limit problem in barNest (I sincerely hope) version 3.0-4 added semi-intelligent bar labelling to the sizetree function added yaxs="i" to the empty plot in twoord.plot (thanks to Giles Crane) added the Wilson binomial CI functions for brkdnNest version 3.0-3 added the ladderplot function (thanks to Peter Solymos) version 3.0-2 rewrote intersectDiagram to better display missing intersections added a correction for character expansion to boxed.labels fixed the count method for barNest version 3.0-1 competely rewrote the barNest family of functions removed labels for empty sets in intersectDiagram version 3.0 fixed some minor problems with oz.windrose (thanks to Brad Evans) added a 'locator' option to zoomInPlot (thanks to Greg Snow) added the 'padj' argument to stackpoly for more tick label control made the 'srt' argument work for both x and y axes in staxlab fixed two little bugs in thigmophobe (thanks to Stephen Milborrow) added the 'add' argument to radial.plot (thanks to Evan Daugharthy) version 2.9-5 added the kiteChart function added the "pos" argument to the getFigCtr function version 2.9-4 added a calculated default vector of axis tick positions to twoord.plot added a "mar" argument to the taylor.diagram function version 2.9-3 added the gamma.col argument to taylor.diagram (thanks to Julian Arnold) added the radial.labels function (thanks to Tali Vardi) added the multiple colors per labels to gantt.chart (thanks to Nicolas Immelman) added the rectFill function added an option to the barp function to use rectFill version 2.9-2 fixed the margin problem in staircase.plot fixed the default y-axis tick placement in barp version 2.9-1 fixed the "big gap" problem in the gap.plot function added the twoord.stackplot function (thanks to Christophe Dutang) version 2.9 added the panes function fixed the border bug in color2D.matplot fixed the indexing bug in drawNestedBars version 2.8-4 added the triax.fill function which necessitated... changed the initial plot call from triax.frame to triax.plot removed the "main" argument from triax.frame added brkdnNest to replace hierobrk rewrote barNest to suit brkdnNest added drawNestedBars for the display of barNest changed all remaining hierobarp functions to barNest version 2.8-3 radical rewrite of the pyramid.plot function fixed up barp example mistake fixed the title position in zoomInPlot rewrote the hierobarp function as barNest version 2.8-2 added the label.cex argument to the gantt.chart function changed the name of the hierobarp function to barNest version 2.8-1 added the calculation of proportions to hierobarp version 2.8 added the cex argument to the staircase.plot function added a bit to the plotCI function examples changed \code tags to \samp and removed formatting from \link tags added the ylog argument to the barp function (thanks to Fatima Kreusch) added the legendg function (thanks to Primoz Peterlin) removed the Piper diagram functions until they run correctly version 2.7-2 added the axislab.cex argument to the twoord.plot function version 2.7-1 added the getMarginWidth function added the bracketing lines and labels to hierobarp added the hierobarp.svymean and hierobarp.svyprop functions added the lwd argument to stackpoly (thanks to Vaclav Varvarovsky) included an example to show how to use gantt.chart without dates included an example of histogram + density curve in twoord.plot version 2.7 added the getFigCtr function removed the final grouping lines from hierobarp version 2.6-4 fixed the bug in hierobrk and hierobarp that got the order of breakdown factors wrong version 2.6-3 fixed the bug in gap.plot that lost the high values version 2.6-2 complete rewrite of the hierobarp and hierobrk functions rewrite of barhier function and name changed to sizetree version 2.6-1 Minor bug fix in the gap.plot function. Version 2.6 Improved bar/line plotting in the twoord.plot function. Added the fullaxis function. version 2.5-5 Changed the default symbol in count.overplot to "1". Added bar plotting to the twoord.plot function. Added fill between the confidence lines to the dispersion function. Added the bumpchart function. (Thanks to Andreas Christofferson for the idea) Added the spreadout function to spread out cramped labels. Added table cell size correction for the cex argument. (Thanks to Brian Diggs for the patch) version 2.5-4 Fixed the bug in dotplot.mtb function. version 2.5-3 Introduced the hierobarp function. Introduced the zoomInPlot function. New version of dotplot.mtb (with bug) previous versions You don't expect me to remember all that, do you? plotrix/NAMESPACE0000644000176000001440000000377012131211523013220 0ustar ripleyusers# created 5/9/2011 - Jim Lemon export( ablineclip, addtable2plot, add.ps, arctext, axis.break, axis.mult, barlabels, barNest, barp, battleship.plot, bin.wind.records, binciWl, binciWu, box.heresy, boxed.labels, brkdn.plot, brkdnNest, bumpchart, categoryReshape, centipede.plot, clean.args, clock24.plot, clplot, cluster.overplot, color.gradient, color.id, color.legend, color.scale, color.scale.lines, color2D.matplot, corner.label, count.overplot, cylindrect, dendroPlot, diamondplot, dispersion, dotplot.mtb, draw.arc, draw.circle, draw.ellipse, draw.radial.line, draw.tilted.sector, drawNestedBars, drawSectorAnnulus, ehplot, emptyspace, fan.plot, feather.plot, floating.pie, fullaxis, furc, gantt.chart, gap.barplot, gap.boxplot, gap.plot, get.breaks, get.gantt.info, get.segs, get.soil.texture, get.triprop, getFigCtr, getIntersectList, getMarginWidth, gradient.rect, hexagon, intersectDiagram, kiteChart, labbePlot, ladderplot, ladderplot.default, legendg, lengthKey, listDepth, makeDendrite, makeIntersectList, maxEmptyRect, mtext3d, multhist, multsymbolbox, oz.windrose, oz.windrose.legend, panes, pasteCols, paxis3d, perspx, pie.labels, pie3D, pie3D.labels, plot.dendrite, plotCI, polar.plot, polygon.shadow, propbrk, psegments3d, ptext3d, pyramid.plot, radial.grid, radial.pie, radial.plot, radial.plot.labels, radialtext, raw.means.plot, rectFill, remove.args, rescale, revaxis, raw.means.plot2, ruginv, size_n_color, sizeplot, sizetree, sliceArray, smoothColors, soil.texture, soil.texture.uk, spread.labels, spreadout, stackpoly, staircase.plot, staxlab, std.error, sumDendrite, sumbrk, symbolbarplot, symbolbox, tab.title, taylor.diagram, textbox, thigmophobe, thigmophobe.labels, triax.abline, triax.fill, triax.frame, triax.plot, triax.points, twoord.plot, twoord.stackplot, valid.n, vectorField, weighted.hist, zoomInPlot ) # methods S3method(plot,dendrite) S3method(print,brklist) plotrix/INDEX0000755000176000001440000001674012070542472012613 0ustar ripleyusersablineclip Display a line like abline but with specified ends add.ps Add p values to a raw means plot addtable2plot Display a table on an existing plot arctext Display text on a circular arc axis.break Put a gap, slash or zigzag "break" in a plot axis axis.mult Display an axis with a multiplier barlabels Display labels on a plot, usually on bars barNest Nested bar plot barNest.svymean Nested bar plot for a svyby result barNest.svyprop Nested bar plot for a svyby result barp A variant of barplot battleship.plot Display a matrix of values as widths of stacked rectangles bin.wind.records Classify wind direction and speed records binciWl Calculate a lower binomial confidence interval binciWu Calculate an upper binomial confidence interval box.heresy A variant boxplot boxed.labels Display text strings in boxes at specified positions brkdn.plot Display summary measures broken down by factors brkdnNest Calculate nested breakdowns of summary measures bumpchart Display a "bumps" chart categoryReshape Convert object/attribute pairs to a matrix centipede.plot Display a centipede plot/caterpillar plot/league table clean.args Remove arguments that would cause an error clock24.plot Plot values as lines/polygon/symbols on a "clockface" clplot Plot lines with colors corresponding to values cluster.overplot Display overlying points as clusters color.gradient Calculate values for a color gradient color.id Find the closest named color to a hexadecimal RGB code color.legend Display a color/value legend color.scale Transform numeric values into a series of colors color.scale.lines Display line segments with scaled colors color2D.matplot Display a numeric matrix as a color matrix corner.label Display a label in one corner of a plot corner.loc Find the location of a corner in a plot count.overplot Display overlying points as the number of points cylindrect Display a rectangle shaded to look like a cylinder dendroPlot Display the distributions of values as branched clusters diamondplot Display one or more polygons on a radial grid dispbars Display dispersion (error) bars dotplot.mtb Display a dotplot in MATLAB style draw.arc Display a circular arc draw.circle Display a circle on an existing plot draw.ellipse Display an ellipse on an existing plot draw.radial.line Display a line or wedge with radial parameters draw.tilted.sector Display a single 3D pie sector drawNestedBars Display the nested bars for barNest ehplot Engelmann-Hecker plot emptyspace Find the largest empty space on a plot fan.plot Display a fan (superimposed pie sector) plot feather.plot Display vectors along a horizontal line floating.pie Display a flat pie chart at a specified position fullaxis Display an axis that runs to the edges of the plot furc Display a 'furcation' (split of a dendrogram) gantt.chart Display a Gantt chart with task priority colors gap.barplot Display a barplot with a range of values omitted gap.boxplot Display boxplots with one or two ranges omitted gap.plot Display a plot with a range of values omitted get.breaks Calculate the breakpoints for weighted.hist get.gantt.info Enter information for a Gantt chart get.segs Calculate the midpoints and limits for centipede.plot get.soil.texture Enter information for soil textures get.triprop Enter triplets of proportions or percentages getFigCtr Get the center of the current figure region in user units getIntersectList Enter the information for an intersection diagram getMarginWidth Calculate the margin width necessary to fit something gradient.rect Display a rectangle with an arbitrary color gradient hexagon Draw a hexagon intersectDiagram Graphically display set intersections kiteChart Display the rows of a matrix of values as polygon widths labbePlot Display a L'Abbe plot ladderplot Display a ladder plot legendg Display groups of fills or symbols in a legend lengthKey Key for interpreting lengths in a plot listDepth Find the maximum depth of a list makeDendrite Build a list of mutually exclusive attributes makeIntersectList Count set intersections maxEmptyRect Find the largest rectangle not containing specified points multhist Plot a multiple histogram as a barplot multsymbolbox Draw boxes filled with symbols representing counts oz.windrose Display an Australian BoM wind rose oz.windrose.legend Display a wind rose legend in Australian BoM style panes Divide the graphics device in a "panel" layout pasteCols Paste the columns of a matrix together paxis3d Display enhanced axes on a 3D plot pie.labels Display flat pie chart labels pie3D Display a 3D pie chart pie3D.labels Display labels on a 3D pie chart plot.dendrite Display a dendrogram for a dendrite object plotCI Display confidence intervals/error bars polar.plot Plot values as lines/polygon/symbols on a 0-360 scale polygon.shadow Display a shadow effect for a polygon propbrk Calculate the proportion of a specified value in a vector pyramid.plot Display a pyramid (opposed horizontal bar) plot radial.plot Plot values as lines/polygon/symbols on radial scale radialGrid Display the grid for radialPlot radialGridLabels Display the grid labels for radialPlot radialPlot Similar to radial.plot but with new argument structure radial.plot.labels Display labels at specified points on a radial plot radialtext Display text in a radial orientation raw,means.plot Display means on a background of raw values rectFill Display a rectangle filled with symbols remove.args Remove specified arguments from argument list rescale Linearly scale a vector of numbers to a new range revaxis Plot with the values on the X or Y axis reversed raw.means.plot2 Wrapper for raw.means.plot to allow more than two factors ruginv Rug plot with inverse coloring size_n_color Display symbols of specified size, color and location sizeplot Display overlying points as larger points sizetree Display hierarchical categories as stacked rectangles smoothColors Build a vector of interpolated colors soil.texture Display a "soil texture triangle" soil.texture.uk Soil texture plot using UK conventions soils Soil texture data from 125 soils spread.labels Spread out labels for irregularly spaced values spreadout Spread out a vector of numbers to minimum intervals stackpoly Plot columns of numbers as overlaid polygons staircase.plot Plot successive values and increments as linked bars staxlab Display staggered labels on an axis std.error Calculate the conventional standard error sumDendrite Sum the first levels of counts in a dendrite list sumbrk Count the number of values equal to a specified value symbolbarplot Barplot with bars filled with symbols : height symbolbox Draw a box filled with symbols tab.title Display the plot title in a tab taylor.diagram Display a Taylor diagram textbox Display justified text in an optional box thigmophobe Find the direction away from the nearest other point thigmophobe.labels Place point labels away from the nearest other point triax.abline Display one or more lines across a triangle plot triax.fill Fill a three axis frame with smaller triangles triax.frame Display a three axis frame with optional grid triax.plot Display a triangle (three axis) plot triax.points Display triplets of values as points on a triangle plot twoord.plot Display a plot with two ordinates of different scales twoord.stackplot twoord.plot but with stacked bars vectorField Display magnitude/direction arrows on a plot weighted.hist Calculate and optionally display a weighted histogram zoomInPlot Display a plot and an expanded rectangular section of it plotrix/DESCRIPTION0000755000176000001440000000143712132162470013517 0ustar ripleyusersPackage: plotrix Version: 3.4-7 Date: 2013-04-13 Title: Various plotting functions Author: Jim Lemon, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, Olivier Eterradossi, Gabor Grothendieck, Michael Toews, John Kane, Rolf Turner, Carl Witthoft, Julian Stander, Thomas Petzoldt, Remko Duursma, Elisa Biancotto, Ofir Levy, Christophe Dutang, Peter Solymos, Robby Engelmann, Michael Hecker, Felix Steinbeck, Hans Borchers, Henrik Singmann,Ted Toal Maintainer: Jim Lemon Description: Lots of plots, various labeling, axis and color scaling functions. License: GPL (>= 2) Packaged: 2013-04-13 02:03:43 UTC; root NeedsCompilation: no Repository: CRAN Date/Publication: 2013-04-13 06:55:20