User Tools

Site Tools


documents:111012rtricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
documents:111012rtricks [2012/02/14 21:37] kotadocuments:111012rtricks [2012/06/13 12:38] kota
Line 52: Line 52:
  
 [{{:documents:rtips:imageplot.png| Example plotting of a matrix using base graphics function image()}}] [{{:documents:rtips:imageplot.png| Example plotting of a matrix using base graphics function image()}}]
 +
 +... a bit faster way calculation wise uses indexing. 
 +<sxh>
 +width <- 10
 +height <- 20
 +x <- c(1:width)
 +y <- c(1:height)
 +xindex <-rep(x, length = width*height)
 +yindex <- yindexing(x, y)
 +
 +z <- xindex + yindex
 +
 +z <- matrix(z, nrow=width, ncol=height)
 +mat <- list(x, y, z)
 +image(x, y, z)
 +
 +yindexing <- function (x, y) {
 +  for(i in y){
 +    cr <- rep(i, length=length(x))
 +    if (i==1) all <- cr
 +    else all <- append(all, cr)
 +  }
 +  return (all)
 +}
 +</sxh>
 +
 +===== Inserting math formula & symbols in label or title =====
 +
 +The easiest way is to use function //expression()//. For example,
 +<code>
 +plot(back$V2, type='l', xlab=expression(slice %.% time), ylab='intensity', xaxt="n", yaxt="n")
 +</code>
 +Inserts vertically centered dot in the x label between "slice" and "time". You could check other available expressions by
 +<code>
 +?plotmath
 +</code> 
 +
 +More recent, but under development is using [[http://cran.r-project.org/web/packages/tikzDevice/|tikzDevice]].
 +
documents/111012rtricks.txt · Last modified: 2020/11/26 07:08 by kota

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki