Reproduce a 3D Plot in R - Data as Matrix, custom axis & labels -


it caused me quite bit of headache... got something, not quite want... so, how can reproduce graph obtain equipment in r?

original graph:

enter image description here

now data graph isn't 100% right (based on initial reading not minimal value during whole run) - plot obtain different, tiny difference, corrected data:

    p1  p2  p3  p4  p5  p6  p7  p8  p9  p10 p11 p12 5   1.356564    0   0   0   0   0   0.522919    0   0.269146    0.899989    0.996454    0 10  1.677049    0.016866    0   0   0   0.607368    0   0   0   0   0.742411    0 15  2.759722    0   0.602542    0   0.548937    0   0   0   0.148181    0   0.224815    0 20  2.383124    0   0   0   0   0   0.142785    0   0   0   0   0 25  2.194318    0.192807    0   1.278415    0   0.939523    0   0.112651    1.068246    1.16061 1.38776 0.676498 30  2.227332    0.658118    0.504237    0   0.760385    0.137248    0   0.376515    1.517327    1.266435    0.489707    0.974562 35  2.425865    0.571249    0.889235    1.315021    0.511195    0   0   0.414589    1.140811    1.845892    0.098323    0 40  2.56984 1.154292    1.163783    0.796667    0.746664    1.091858    1.122893    1.687882    2.061788    2.724509    2.308096    1.235134 45  2.71372 2.702534    2.704258    2.23746 2.314217    1.892822    1.86525 2.357875    2.554184    1.95893 1.188201    1.71474 50  2.84702 2.649788    2.113081    1.130567    1.357824    0.92954 1.419298    0.995268    0.548421    0.91788 0   0.024919 55  3.283965    0.843004    2.172512    1.763155    0.791001    0.874469    0.548028    1.039265    0.898974    0.227216    1.265553    0.581115 60  4.22087 2.367116    2.663145    2.21502 1.698861    0.571813    1.16839 0.594161    0.585841    0   0   0 65  3.905396    1.513722    2.426271    1.706694    1.34067 1.325783    0.490957    1.981992    0.235005    0.934454    0.940276    0.846207 70  4.649299    2.569352    2.811965    2.19341 2.635729    1.002647    0.915708    1.924824    0.794212    1.294401    1.157521    0.880585 75  4.103029    2.051672    2.758758    2.976522    2.188941    2.07245 2.149921    1.770336    2.685513    1.092814    1.355365    1.008754 80  4.531421    2.321935    3.618583    2.991384    2.537042    1.402546    1.431915    2.2841  1.387641    0.920552    2.044487    0.690089 85  5.199451    3.74389 3.736395    3.487242    2.09652 2.173166    1.911587    1.661859    1.755795    1.590398    1.545263    0.453356 90  5.3198  4.528225    4.328908    4.135772    2.374012    2.560562    2.979826    1.757164    2.13082 2.583608    2.522267    1.471753 95  5.676048    4.557345    5.179662    4.539891    4.028275    2.732066    3.528498    3.509869    2.473462    2.518212    2.026832    1.273347 100 6.53704 5.714319    6.743194    5.071138    3.87076 3.521927    2.769212    3.186856    2.466066    2.562069    1.546379    1.645076 105 6.870514    5.497576    5.636102    5.347473    4.649386    3.425513    3.473505    3.762797    2.721337    2.166123    2.366901    1.826227 110 6.813474    6.881328    5.637504    5.145343    3.972123    4.052656    2.745163    3.562568    4.188948    2.960847    3.056323    2.059925 115 7.719027    7.035191    7.379664    6.839802    5.063594    4.505035    4.020032    4.451296    4.72488 3.22288 3.514651    3.258859 120 8.504394    8.382436    7.485067    6.26145 5.311175    4.512194    4.223568    3.851785    3.984909    2.583755    3.97142 1.825233 125 8.531664    7.561645    8.172427    6.090729    5.211048    5.419967    3.921543    5.067175    4.272155    3.653463    2.593495    2.604687 

the data presented in external file read in r , far produces this:

enter image description here

i using persp , messy manual axis labelling delta_t, isn't ideal... nice if employ header , label column/row matrix, column/5 cycle number , position number p1 p12... ideally ticks, , nice able plot lines scale @ too... (i did fiddle volcano sample can give me grids, can't plot pdf more interactive... )

the below code use, open alternative solutions well:

datain <- as.matrix(read.table("processed banner data.txt",row.names=1,header=true))  hiretsout <- datain[,c(12:1)]  z <- hiretsout  ## colouring method presentation on r plots nrz <- nrow(hiretsout) ncz <- ncol(hiretsout)  jet.colors <- colorramppalette( c("blue","green","yellow","orange","red")) nbcol <- 100 color <- jet.colors(nbcol) zfacet <- z[-1,-1] + z[-1, -ncz] + z[-nrz,-1] + z[-nrz,-ncz] facetcol <- cut(zfacet, nbcol)   pdf("hirets-banner.pdf",6,5) par(mar=c(2,2,1,2))  pmat <-  persp( hiretsout, col=color[facetcol], zlim= range(0,200), xlab="cycle number", ylab="position number", zlab="\n\ndelta t", theta=-60, phi=10, box=true, #box=false, #axes=false axes=true )   ## long , messy resurce axis labelling, gets job done (to extent) ## http://entrenchant.blogspot.co.uk/2014/03/custom-tick-labels-in-r-perspective.html  x.axis <- 0:1 min.x <- 0 max.x <- 1 y.axis <- 0:1 min.y <- 0 max.y <- 1 z.axis <- seq(0, 200, by=20) min.z <- 0 max.z <- 20  tick.start <- trans3d(max.x, min.y, z.axis, pmat) tick.end <- trans3d(max.x, (min.y - 0.025), z.axis, pmat) segments(tick.start$x, tick.start$y, tick.end$x, tick.end$y)  tick.start <- trans3d(min.x, max.y, z.axis, pmat) tick.end <- trans3d(min.x - 0.025 , max.y, z.axis, pmat) segments(tick.start$x, tick.start$y, tick.end$x, tick.end$y)   labels <- as.character(z.axis) label.pos <- trans3d(max.x, (min.y - 0.05), z.axis, pmat) text(label.pos$x, label.pos$y, labels=labels, adj=c(0, na), cex=0.75)  labels <- as.character(z.axis) label.pos <- trans3d(min.x, (max.y + 0.1), z.axis, pmat) text(label.pos$x, label.pos$y, labels=labels, adj=c(1, na), cex=0.75)   dev.off() 

i can plot lines same method plot ticks, overlay on surface , looks bit ugly...

given how many plotting questions there on r, maybe possible develop kind of general wiki style entry can others?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -