inst/doc/plotting.R

## ----setup, include=FALSE, cache=FALSE-----------------------------------
library("knitr")
#options(replace.assign=TRUE,width=60)
library("knitr")
opts_chunk$set(fig.path='knitr_figure/graphics-', 
               cache.path='knitr_cache/graphics-', 
               fig.align='center', 
               fig.height=3)

knit_hooks$set(crop=hook_pdfcrop)


## ----echo=FALSE----------------------------------------------------------
ev = FALSE


## ----eval=FALSE----------------------------------------------------------
## ## Basic plots
## plot(x,y); hist(x); barplot(table(x))
## boxplot(x); stem(x); pie(x)
## pairs(matrix) #Scatterplots
## coplot()# conditional plot
## stripplot()# strip plot
## qqplot() # quantile-quantile plot
## qqnorm(); qqline()# fit normal distribution
## ## Standard plotting arguments
## xlab = "x-axis label" #See also ylab
## xlim = c(0, 10)#x axis range
## main = "Main title"
## sub = "sub title"


## ----echo=FALSE,crop=TRUE, out.width='0.9\\linewidth',fig.pos="h"--------
plot(0:1, 0:1,  type="n", axes=FALSE, cex=2, xlab="", ylab="", xlim=c(-0.2, 1.1))
x = seq(0,1,length.out=8)
epsilon = 0.05
for(i in 1:8) 
  polygon(c(x[i]+epsilon,  x[i]+epsilon, x[i]-epsilon, x[i]-epsilon), c(0.2,0.7,0.7,0.2), col=i)

text(x, 0.8, 1:8)
text(x, 0.05, palette(), cex=0.8)


## ----echo=FALSE,fig.pos="!h",crop=TRUE, out.width='0.95\\linewidth',-----
plot(0:1, 0:1, type="n", axes=FALSE, cex=2, xlab="", ylab="", ylim=c(-0.1, 1.1))
y = seq(0,1,length.out=6)
segments(0.25, y, 1, y, lty=6:1, lwd=3)
labels = c('1: "solid"','2: "dashed"', '3: "dotted"', '4: "dotdash"', '5 "longdash"', '6: "twodash"')
text(0.05, y, labels, cex=0.9)


## ----echo=FALSE,crop=TRUE, out.width='0.95\\linewidth',fig.pos="h"-------
x = rep(1:13, 2)[1:26]
y = rep(1:2, each=13)[1:26]
plot(x, y, pch=0:25, bty="n", axes=FALSE, ylim=c(0.5,2.5), xlim=c(1, 13.5),
     xlab="", ylab="", cex=2)
text(x+0.3, y + 0.3, 0:25, cex=0.9)

Try the nclRcourses package in your browser

Any scripts or data that you put into this service are public.

nclRcourses documentation built on May 2, 2019, 5:55 p.m.