Forum: help


RE: Problem: White lines on levelplot [ Reply ] By: Randall Goodwin on 2011-09-28 06:04 | [forum:5006] |
Try reading and running this. Let me know if it clears up your white lines. Would love to see the before and after if possible :) Regards, Randall ##################################### library(lattice) library(Cairo) #install it if you don’t have it. # makes some interesting data to plot x <- y <- seq(-1,1,.005) dataGrid <- data.frame(expand.grid(x=x,y=y)) # Base graphics image() is similar to lattice levelplot(). # But it takes x, y and z where z is a matrix z <- with(dataGrid, x * exp(-x^2 - y^2)) dim(z) <- c(length(y), length(y)) # Plot the image. It has the ugly white lines (at least on my win7/64 PC). image(x,y,z, xlim=c(-1,1), ylim=c(-1,1), asp=1) # Plot the image with an option. Voila, lines are gone! # But there is no color key on this plot :( image(x,y,z, xlim=c(-1,1), ylim=c(-1,1), asp=1, useRaster=TRUE) # levelplot() from lattice will take either the matrix or a dataframe. # Let’s try with the matrix first, since we have it already. # This also has ugly white lines in the plot :( lp1 <- levelplot(z, aspect = "iso", xlim=c(-1,1), ylim=c(-1,1), row.values = x, column.values = y) plot(lp1) # Here is the levelplot method for data frames. What you are using. # Syntax is bit easier, but still has the white lines. lp2 <- levelplot(z ~ x * y, aspect = "iso", data = dataGrid) plot(lp2) # Using the non-default panel function for levelplot makes the white # The lines disappear. I highly recommend the book on Lattice if you # plan to do statistical plotting frequently. lp3 <- levelplot(z ~ x * y, aspect = "iso", data = dataGrid, raster = TRUE, # this only rasters the key! (not working?? Key still has white lines) panel = function (x,y,z, ...){ panel.levelplot.raster(x, y, z,...) }) plot(lp3) # Note. Other graphics devices will automatically raster, but they may # struggle plotting really big data. CairoWin() plot(lp2) # the "bad" lattice levelplot is now good! |
RE: Problem: White lines on levelplot [ Reply ] By: David Roberts on 2011-09-14 18:52 | [forum:4958] |
No, I never did find a solution for this. I suppose I will have to make final images in ArcGIS or some other software. I did try it on several computers with different display resolutions, etc. with no success. Please do let me know if you sort it out! |
RE: Problem: White lines on levelplot [ Reply ] By: Aaron Petty on 2011-09-12 02:23 | [forum:4946] |
Hi David, Did you ever find a solution to this? I'm having a similar problem, although in my case it's just horizontal lines. The code I used is: levelplot( Z ~ x * y | factor(tau) ,data=myFrame, at=c(0,1,10,50,100), col.regions= Colours, colorkey = T, strip = function(...,var.name, strip.names,bg) strip.default(..., var.name = expression(tau), strip.names = c(TRUE,TRUE), bg="white"), scales=list(arrows = F, cex=1.2),add=T) |
RE: Problem: White lines on levelplot [ Reply ] By: David Roberts on 2011-03-12 01:07 | [forum:4124] |
Sorry, here's my code. Pretty basic: > levelplot(Y~X*Y,pch=15,cex=0.1,aspect="iso") I have played with the cex, etc. settings to no avail. - David |
Problem: White lines on levelplot [ Reply ] By: David Roberts on 2011-03-12 01:04 | [forum:4123] |
I'm trying to produce a levelplot with a large dataset (900,000 rows) based on an X, Y, and Z value. Data sample: X Y Z -2851500 10152500 0.0000 -2847500 10152500 0.0000 -2843500 10152500 0.0000 -2239500 10152500 0.1225 -2871500 10148500 0.2536 -2867500 10148500 0.0358 -2863500 10148500 0.8996 -2859500 10148500 0.0000 -2855500 10148500 0.0000 -2851500 10148500 0.0000 -2247500 10148500 0.0000 ... All Z values are between 0 and 1. Most Z values are 0. X and Y are UTM coordinates. The datafile is an incomplete (not rectangular) grid at XY intervals of 4000 for western North America. The code seems to work fine and all is well, except that I get white vertical and horizontal lines across the plot. I suspected that this was a memory issue, especially given the clean output for half the plot, but cropping down the data to a small set (within the completed part) didn't solve the problem. I have posted a sample image here: http://www.ualberta.ca/~drr3/R/LevelPlot_Issue.png (and uploaded an image). I would appreciate any help with this. Thanks in advance. - David |