lattice

plot the first point of each group of panel data in lattice xyplot

对着背影说爱祢 提交于 2019-12-13 14:44:13
问题 I'm trying to create a line plot using groups and panels that superposes a symbol on the first value of each group. This attempt plots the first point of the first group only and does nothing for the other two groups. library(lattice) foo <- data.frame(x=-100:100, y=sin(c(-100:100)*pi/4)) xyplot( y~x | y>0, foo, groups=cut(x,3), panel = function(x, y, subscripts, ...) { panel.xyplot(x, y, subscripts=subscripts, type='l', ...) # almost but not quite: panel.superpose(x[1], y[1], subscripts

Plotting multiple lines R [duplicate]

人盡茶涼 提交于 2019-12-13 10:31:43
问题 This question already has answers here : Multiple curves with same Time x-axis in R (2 answers) Closed 6 years ago . I have the following data: dim tuples buckets error is.init 1 5 13500000 50 0.29 TRUE 2 5 13500000 100 0.28 TRUE 3 5 13500000 150 0.27 TRUE 4 5 13500000 200 0.26 TRUE 5 5 13500000 250 0.26 TRUE 6 4 360000 50 0.10 TRUE 7 4 360000 100 0.09 TRUE 8 4 360000 150 0.09 TRUE 9 4 360000 200 0.09 TRUE 10 4 360000 250 0.09 TRUE 11 3 9000 50 0.10 TRUE 12 3 9000 100 0.09 TRUE 13 3 9000 150

X scale values very compacted on R plots with lattice

只谈情不闲聊 提交于 2019-12-13 07:57:38
问题 I'm using this code to generate a plot: require(lattice) allcol <- c("blue","chocolate4","cornflowerblue","chartreuse4","brown3","darkorange3","darkorchid3","red","deeppink4","lightsalmon3","yellow","mistyrose4","seagreen3","green","violet","palegreen4","grey","slateblue3","tomato2","darkgoldenrod2","chartreuse","orange","black","yellowgreen","slategray3","navy","firebrick1","darkslategray3","bisque3","goldenrod4","antiquewhite2","coral","blue4","cyan4","darkred","orangered","purple4",

lattice: Clustered Barchart: Sort bars and display values at top of bars

橙三吉。 提交于 2019-12-13 07:32:33
问题 I am working on a child sexual abuse research. For this, I want to prepare a clustered bar chart using lattice . I used the following code. My data: nature <- read.table(text = "Nature_of_sexual_abuse, Familiarity_with_the_perpetrator, Count Talked in a sexual way, Not familiar at all, 21 Talked in a sexual way, Not very familiar, 22 Talked in a sexual way, Very familiar, 22 Shown pornography, Not familiar at all, 6 Shown pornography, Not very familiar, 17 Shown pornography, Very familiar, 16

Error bar lattice dotplot

纵饮孤独 提交于 2019-12-13 05:24:56
问题 I want to represent a tree factor dotplot with error bar combined with boxplot. I have complete almost all the graphic except that my error bar are overlapped. Concretely my idea is to jitter the dots and the error bars set.seed(1) data<-sample(rnorm(50,2,2),40) sd<-sample(rnorm(50,0.2,2),40) factor<-sample( LETTERS[1:3], 40, replace=TRUE, prob=c(0.3,.3, 0.3) ) frame<-data.frame(data,sd,factor) frame<-as.data.frame(frame) up=frame$data+frame$sd lo=frame$data-frame$sd bwplot(data ~ factor,

RGB colors in a raster cube visualization in R

萝らか妹 提交于 2019-12-13 04:25:51
问题 I am using the package mapview to plot a 3D raster cube from a raster stack . > S2_images class : RasterStack dimensions : 660, 1074, 708840, 6 (nrow, ncol, ncell, nlayers) resolution : 10, 10 (x, y) extent : 219800, 230540, 4097480, 4104080 (xmin, xmax, ymin, ymax) coord. ref. : +proj=utm +zone=30 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 names : L2A_T30ST//51_B02_10m, L2A_T30ST//51_B03_10m, L2A_T30ST//51_B04_10m, L2A_T30ST//51_B08_10m, L2A_T30ST//51_B11_20m, L2A_T30ST//51

how to create a stacked area chart in lattice?

大憨熊 提交于 2019-12-13 00:54:00
问题 Consider this simple tibble tibble(time = c(ymd('2019-01-01'), ymd('2019-01-02'), ymd('2019-01-03'), ymd('2019-01-04'), ymd('2019-01-05')), var1 = c(1,2,3,4,5), var2 = c(2,0,1,2,0)) # A tibble: 5 x 3 time var1 var2 <date> <dbl> <dbl> 1 2019-01-01 1 2 2 2019-01-02 2 0 3 2019-01-03 3 1 4 2019-01-04 4 2 5 2019-01-04 5 0 I would like to create a stacked area chart using lattice , where time is on the x axis and var1 and var2 are stacked (on the y axis) over time. Is it possible to do so? Thanks!

Personalize X axis values display on R using lattice

冷暖自知 提交于 2019-12-12 15:54:00
问题 I have a huge collection of data with date, client and its NFS usage. I'm using lattice R package for plotting, as adviced on superuser. Also, Stackoverflow helped me on converting the date string to an actual date object. Now, my code is this: require(lattice) logfile <- read.table(file="nfsclients-2d.log") names(logfile) <- c("Date","Client","Operations") allcol <- c("blue","chocolate4","cornflowerblue","chartreuse4","brown3","darkorange3","darkorchid3","red","deeppink4","lightsalmon3",

several hexbin plots on one PDF page in R

て烟熏妆下的殇ゞ 提交于 2019-12-12 15:16:54
问题 I'm trying to create a PDF with a number of hexbin plots where I'd like to have a particular number of plots per page. This one works: PDFPath = "C:\\temp\\some.pdf" pdf(file=PDFPath) par(mfrow = c(2,2)) for (i in seq(5,10)) { VAR1 = rnorm(i) VAR2 = rnorm(i) plot(VAR1, VAR2) } dev.off() This one doesn't work. It only generates one plot per page: library(hexbin) PDFPath = "C:\\temp\\some.pdf" pdf(file = PDFPath) par(mfrow = c(2,2)) for (i in seq(5,10)) { VAR1 = rnorm(i) VAR2 = rnorm(i) plot

Add 3D abline to cloud plot in R's lattice package

ぐ巨炮叔叔 提交于 2019-12-12 14:25:13
问题 I want to add a 3D abline to a cloud scatterplot in R's lattice package. Here's a subset of my data (3 variables all between 0,1): dat <- structure(c(0.413, 0.879, 0.016, 0.631, 0.669, 0.048, 1, 0.004, 0.523, 0.001, 0.271, 0.306, 0.014, 0.008, 0.001, 0.023, 0.670, 0.027, 0.291, 0.709, 0.002, 0.003, 0.611, 0.024, 0.580, 0.755, 1, 0.003, 0.038, 0.143, 0.214, 0.161, 0.008, 0.027, 0.109, 0.026, 0.229, 0.006, 0.377, 0.191, 0.724, 0.119, 0.203, 0.002, 0.309, 0.011, 0.141, 0.009, 0.340, 0.152, 0.545