lattice

Controlling the number of panels in a lattice plot with R

How do I limit the number of panels shown on a single page using lattice? I am graphing the results of a regression for multiple states and putting 50 of these on a single page makes them unreadable. I would like to limit the output to 4 wide and as many tall as needed. Here's my lattice code: xyplot(Predicted_value + Actual_value ~ x...

plotting two vectors of data on a GGPLOT2 scatter plot using R

I've been experimenting with both GGPLOT2 and lattice to graph panels of data. I'm having a little trouble wrapping my mind around the GGPLOT2 model. In particular, how do I plot a scatter plot with two sets of data on each panel: in Lattice I could do this: xyplot(Predicted_value + Actual_value ~ x_value | State_CD, data=dd) and tha...

Plotting a wireframe AND a cloud with lattice in R

I have a nice surface that represents nonlinear multi-part regression results on a regression with two independent variables. I would like to plot the regression predicted values as a nice 3D surface and then show the actual values as point that bounce around the surface. This would be the 3D version of plotting a regression line and sho...

Lattice problems: lattice objects coming from JAGS, but device can't be set

Hi All, I ran JAGS with runjags in R and I got a giant list back (named results for this example). Whenever I access results$density, two lattice plots (one for each parameter) pop up in the default quartz device. I need to combine these with par(mfrow=c(2, 1)) or with a similar approach, and send them to the pdf device. Nothing I tried...

Set rank of array at runtime

Hi, I was wondering what the simplest way would be to implement an array who's rank is specified at runtime. The example I am working on stores a array of boolean values for lattice points, and I want the user to be able to chose how many spatial dimensions the model uses at runtime. I've looked at the Array.newInstance() method: dim...

[R] add labels to lattice barchart

I would like to place the value for each bar in barchart (lattice) at the top of each bar. However, I cannot find any option with which I can achieve this. I can only find options for the axis. ...

Saving dotplot to pdf in R

I am having trouble saving a dotplot to pdf when this command is done inside a function. It works fine when called normally: df <- data.frame(a = runif(10), b = runif(10), c = runif(10), x = 1:10) pdf("test.pdf") dotplot(a + b + c ~ x, data = df, type = "l", auto.key=TRUE) dev.off() But if this code is inside a function, it wil...

How to draw a chart with sorted horizontal error bars (sorted barcharts with error marks)?

I would like to plot means and standard errors as a horizontal barchart, and I want the mean sorted. I've found the way to plot horizontal sorted barcharts using lattice, but I do not know how to add error marks. The following are my data and the R code I came up with. data <- structure(c(0.67, 0.67, 0.76, 0.66, 0.71, 0.6, 0.52, 0.6, ...

Lattice: multiple plots in one window?

I'm trying to put multiple lattice plots in one window using levelplot by setting par(mfrow=c(2,1)) but it seems to be ignoring this. Is there a particular function for setting multiple plots in lattice? ...

Fortran recursion segmentation faults

Hey all - I have to design and implement a Fortran routine to determine the size of clusters on a square lattice, and it seemed extremely convenient to code the subroutine recursively. However, whenever my lattice size grows beyond a certain value (around 200/side), the subroutine consistently segfaults. Here's my cluster-detection rout...

R: What are the pros and cons of using Lattice versus ggplot2?

R: What are the pros and cons of using Lattice versus ggplot2? ...

Using Mathematica to generate crystal lattices

How do you generate a 3x3x3 lattice in Mathematica? Is it possible to color some of the lattice points? It seems that it is possible but I cannot get it to work so far http://reference.wolfram.com/mathematica/ref/LatticeData.html What I mean by 3x3x3 is something like figure (c) on the right:http://physics.ucsd.edu/was-sdphul/labs/2dl/...

Utilise Surv object in ggplot or lattice

Anyone know how to take advantage of ggplot or lattice in doing survival analysis? It would be nice to do trellis/facet like survival graphs. So in the end I played around and sort of found a solution for a kaplan meier plot. Apologize for the messy code in taking the list elements into a dataframe, but I couldnt figure out another wa...

R:lattice.qq How do I do a multi-panel plot of treatment[x] vs control?

I have a dataframe that looks like this: str(Data) 'data.frame': 11520 obs. of 29 variables: $ groupname : Factor w/ 8 levels "Control","Treatment1",..: 1 1 1 1 1 1 1 1 1 1 ... $ fCycle : Factor w/ 2 levels "Dark","Light": 2 2 2 2 2 2 2 2 2 2 ... $ totdist : num 0 67.5 89.8 109.1 58.3 ... #etc. I can do a single plot o...

display values in stacked lattice barchart [R]

Hi, I want to display the values of a 100% bar for each part of it. Unfortunately I don't know how to do it. The graph should be in lattice because of the legend position (I tried it with ggplot2, but you can't show the legend in one row). I'm pleased about any suggestions or ideas. Thanks, Sebastian library(lattice) data(postdoc, pac...

Adding lines and labels in lattice barchart [R]

Hi, I have two questions concerning customizing a barchart in lattice. I tried to add labels to the barchart respectively edit the scale, but my code doesn't work. What I'm doing wrong? There should be some values including "%". The second question is how lines can be drawn between the top and the bottom of the plotting area behind the ...

Selecting k sub-posets

I ran into the following algorithmic problem while experimenting with classification algorithms. Elements are classified into a polyhierarchy, what I understand to be a poset with a single root. I have to solve the following problem, which looks a lot like the set cover problem. I uploaded my Latex-ed problem description here. Devising...

stacked barchart with lattice: is my data too big?

I want a graph that looks similar to the example given in the lattice docs: #EXAMPLE GRAPH, not my data > barchart(yield ~ variety | site, data = barley, + groups = year, layout = c(1,6), stack = TRUE, + auto.key = list(points = FALSE, rectangles = TRUE, space = "right"), + ylab = "Barley Yield (bushels/acre)...

Dynamically generate an R lattice graph for many fields

I'm wondering if the following is possible. I have a survey with 100+ questions, all categorical, collected in 4 locations. All questions are labeled q1, q2 and so on. Let's say there are 100 for simplicity. I can visually compare the results of a particular question across locations with: library (lattice); histogram(~ q75 | location...

R: How to superimpose distribution curves on histograms using ggplot2 and lattice

Say, I am using facet_grid() in ggplot2 to obtain 2 histograms. Now I want to superimpose these histograms with Poisson curves (having different means for the 2 histogram plots/grids) and a second curve of another distribution (for which I want to manually provide the probability function of values). How can this be done? constructing ...