[R] function: ploting an igraph object within lattice
Hi, I would like to be able to develop a function to plot an igraph object with lattice (trellis type displays will be usefull for grouping etc). Anyway, I mostly feeble Igraph requires that you convert two columns of data two an igraph object and to be able to plot the graph...I have tried a very, very simplistic (if not naive) approach and surprise, surprise, it didn't work. First of all, does anyone know any good tutorial packages/books that will help someone like me unused to programming develop their function writing skills, and secondly, can anyone suggest a way to generate an igraph object in lattice. Thanks Andrew ##generates the igraph plot library(igraph) LE-read.csv(LE.csv) LG-graph.data.frame(LE, directed=F) LG$layout-layout.kamada.kawai(LG) plot(LG, vertex.size=4, vertex.label=NA, vertex.color=red, vertex.shape=square, edge.color=blue4) ## ## library(lattice) ## ## xyplot.igraph - function(plot.igraph, ...) { dat - graph.data.frame(x = object, directed=FALSE) prepanel=prepanel.igraph } prepanel.igraph - function(x, axes=FALSE, xlab=, ylab=, add=FALSE, xlim=c(-1,1), ylim=c(-1,1), main=, sub=) http://www.nabble.com/file/p25855220/LE.csv LE.csv -- View this message in context: http://www.nabble.com/function%3A-ploting-an-igraph-object-within-lattice-tp25855220p25855220.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot key
Hi, I'm having trouble matching the symbols/color of the key to match those specifiec in the plot. Here is the code I used: xyplot(GCR+GCT ~ FRAC, data=RWF, type=c(g,p),cex=1.2,pch=c(22,21), xlab=expression(italic(f)),ylab=expression(italic(S)), key=list(points=list(pch=c(22,21),cex=1.2), text=list(c(Targeted Deletion,Random Deletion I'm, sorry if this is an apparently easy/obvious mistake on my part. With thanks Andrew http://www.nabble.com/file/p25681535/RWF.csv RWF.csv -- View this message in context: http://www.nabble.com/xyplot-key-tp25681535p25681535.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot lmline: error message.
Hi, I am trying to produce an xyplot with a regression line. The data should be represented as log/log but when I fit the lmline I receive an error message - the plot is fine without the log transformation, but the then the plot is meaningless. I know it must be something simple, but I just can't see it. Hope someone can help... Thanks. xyplot(log(Pk)~log(k),data=rwpk,cex=1, panel=function(x,y){ panel.grid(h=-1, v=-1) panel.xyplot(x,y,cex=1.0) panel.lmline(x,y) }) http://www.nabble.com/file/p25641684/rwpk.csv rwpk.csv -- View this message in context: http://www.nabble.com/xyplot---lmline%3A-error-message.-tp25641684p25641684.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mixed font in lattice xyplot lables
Hi all, can anyone suggest a reason as mto why my xlab is plotting this text at oposite ends of axis. I would like to represent my lable like this: Moran's I ...but with the I in italics. For some reason they seperate and position at oposite ends of the axis?? Thank you library(lattice) dat - data.frame(x = rnorm(10),y = rnorm(10)) xyplot(y ~ x, dat,xlab=expression(Moran's ,italic(I))) -- View this message in context: http://www.nabble.com/Mixed-font-in-lattice-xyplot-lables-tp25626332p25626332.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Polygon issue in lattice Bivariate density estimation
Dear all, I am trying to set a specific bandwidth for a bivariate kernel density estimation and then plot it in lattice: managed all that except that the plot appears to have an issue regards the setting of the polygon and as a result I end up with horizontal lines disecting my plotting region. If I lower the bandwidth excessively then the issue resolves itself, but this defeats the object as I wish and need h=0.8481. Any suggestions would be much appreciated. Thank you Here is the code I have used: library(lattice) library(KernSmooth) # CAPEL2=read.csv(CAPEL2.csv,header=T,row.names=1) # panel.density2d - function(x, y, nlevels = 10, bandwidth, ...) { k2d - bkde2D(na.omit(cbind(x, y)), bandwidth = bandwidth) cl - contourLines(x = k2d$x1, y = k2d$x2, z = k2d$fhat, nlevels = nlevels) lapply(cl, panel.polygon, ...) } # xyplot(PCO2~PCO1,data=CAPEL2,panel = panel.density2d,bandwidth=0.8481) http://www.nabble.com/file/p18893107/CAPEL2.csv CAPEL2.csv -- View this message in context: http://www.nabble.com/Polygon-issue-in-lattice---Bivariate-density-estimation-tp18893107p18893107.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Lattice: Changing the names of conditional variables in strips to mathematical expressions
Hi, I know this has come up before, but I am having a hard time getting any of the solutions I have found to work! I am trying to change the conditioning variable names in my xyplot from the default names as they appear from the data table - see following: X=densityplot(~density|type,data=Query,plot.points=jitter,ref=TRUE,width=sj, panel=function(x, ...){ panel.grid(h=-1, v=-1) panel.densityplot(x, ...) }) X to dimnames(X)[[1]] - expression((sqrt(Gower^{1})),(sqrt(Kulczynski)) X The key issue is gaining the square root symbols and superscript position of the 1 ... As an aside, it is possible to vary the font type within expression? Say setting the text to italics but leaving the superscript 1 as ariel? Suggestion would be greatly appreciated Thank you Andrew http://www.nabble.com/file/p18787745/Query.csv Query.csv -- View this message in context: http://www.nabble.com/Lattice%3A-Changing-the-names-of-conditional-variables-in-strips-to-mathematical-expressions-tp18787745p18787745.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re creating Procrustes Plot in Lattice
Hi, I have been trying to create a function to generate a Procrustes plot, generated from package vegan in lattice. standard vegan code as follows library(vegan) pro=protest(P1, P8, permutations=4999,choices=1:4) plot(pro) Now, here is the code for the function that I have failed to get to work properly. panel.procrustes=function(x,y) }Pro=protest(x,y,permutations=4999,choices=1:4) Proplot=plot(Pro) } xyplot(P1[1:4]~P8[1:4],panel=panel.procrustes) I can generate an empty plot, but not much else - hope someone can help and point out the obvious! Kind regards Andrew http://www.nabble.com/file/p18731653/P1.csv P1.csv http://www.nabble.com/file/p18731653/P8.csv P8.csv -- View this message in context: http://www.nabble.com/Recreating-Procrustes-Plot-in-Lattice-tp18731653p18731653.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Mathematical annotation in lattice strip: Is it possible?
I have tried without success to find a way including the square root symbol in lattice strips as part of my conditioning labels. I have tried supplementing by creating a list of vectors using the var.name function coupled with the expression function used in xlab/ylab. xyplot(adjusted_Rand_index~cluster|distance_measure, main=Level of agreement between partitions: Wards Method, ylab=Coefficient value (adjusted rand index), xlab=number of clusters, type=l, data=randA1, strip=strip.custom(varnames=c(expression(sqrt(Bray-Curtis))) Is there a way of generating the square root symbol inside the strip or am I wasting my time. Thank you very much Regards Andrew http://www.nabble.com/file/p17187888/randA1.csv randA1.csv -- View this message in context: http://www.nabble.com/Mathematical-annotation-in-lattice-strip%3A-Is-it-possible--tp17187888p17187888.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] inserting mathematical symbols in lattice strip
I have tried without success to find a way including the square root symbol in lattice strips as part of my conditioning labels. I have tried supplementing by creating a list of vectors using the var.name function coupled with the expression function used in xlab/ylab. xyplot(adjusted_Rand_index~cluster|distance_measure, main=Level of agreement between partitions: Wards Method, ylab=Coefficient value (adjusted rand index), xlab=number of clusters, type=l, data=randA1, strip=strip.custom(varnames=c(expression(sqrt(Bray-Curtis))) Is there a way of generating the square root symbol inside the strip or am I wasting my time. i.e. converting Bray-Curtis to ... [sqrt symbol] Bray-Curtis. Thank you very much Regards Andrew http://www.nabble.com/file/p17188291/randA1.csv randA1.csv -- View this message in context: http://www.nabble.com/inserting-mathematical-symbols-in-lattice-strip-tp17188291p17188291.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in downViewport.vpPath(vpPathDirect(name)
Hi, I am having trouble plotting a series of dendrograms using lattice and grid code as found in Paul Murrells book R Graphics. This is the error message I recieve: Error in downViewport.vpPath(vpPathDirect(name), strict, recording = recording) : Viewport 'plot1.panel.1.1.off.vp' was not found I have attached the code and also my data file. Should anyone have any suggestions then your help would be gratefully appreciated. Thank you Andrew http://www.nabble.com/file/p17017801/dend4c.txt dend4c.txt http://www.nabble.com/file/p17017801/gL2.csv gL2.csv -- View this message in context: http://www.nabble.com/Error-in-downViewport.vpPath%28vpPathDirect%28name%29-tp17017801p17017801.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.