lattice

Multiple ablines in xyplot

删除回忆录丶 提交于 2019-12-12 12:13:25
问题 I have a "long" dataframe defined as: q <- data.frame(Indicator.Code=factor(),Year=numeric(),Value=numeric()) and am trying to plot in a single xyplot the values as a function of the year, for each different Indicator.Code , as follows xyplot( Value~Year,data=q,group=Indicator.Code) So far, so good. Now I am trying to add lines corresponding to the linear regressions rlm(q$Value[q$Indicator.Code==a]~q$Year[q$Indicator.Code==a]) for all the values of Indicator.Code . I do not know how to do it

Lattice dotplot conditional fill color

谁都会走 提交于 2019-12-12 11:29:22
问题 Problem: I have a data frame, which I want to visualize with lattice's panel dot plot (not ggplot2). It contains a variable which should be used conditionally to highlight data by different color fill. Reproducible example: require(lattice) # Make reproducable data frame df= mtcars df= cbind(car = rownames(df), df) rownames(df)= NULL df=df[1:5, c("car", "mpg", "cyl", "carb")] df # output: # car mpg cyl carb # Mazda RX4 21.0 6 4 # Mazda RX4 Wag 21.0 6 4 # Datsun 710 22.8 4 1 # Hornet 4 Drive

Histogram on Lattice

那年仲夏 提交于 2019-12-12 08:07:45
问题 Since hist() of the base R does not report percentages (and the freq=FALSE) does not help either, I turned to lattice . histogram(rnorm(10000)) Please help me with the following: How can I get rid of the box arround the plot? How can I seperately define the cex of the x/y labels and x/y axis? How can I provide custom names to x and y axis? 回答1: This should get you started: library(lattice) histogram(rnorm(10000), main=list( label="Main plot title", cex=1.5), xlab=list( label="Custom x-axis

How to add lines to a levelplot made using lattice (abline somehow not working)?

夙愿已清 提交于 2019-12-12 07:23:52
问题 I want to draw horizontal and vertical lines on my level plot corresponding to x values from 74 to 76 and y values from 28 to 32. Below is my R code. But when I run the following,I get the levelplots but no lines. I also recieve no error from R. The default theme on my installation is something which maps the values to pink and cyan. I have also tried using the panel function but no luck with that as well. levelplot(d_fire_count_nom ~ longitude + latitude | factor(day)+factor(year), data =

How to superimpose a histogram on each panel

懵懂的女人 提交于 2019-12-12 06:23:31
问题 I would like to superimpose, on each lattice histogram panel, an additional histogram (which will be the same in each panel). I want the overlayed histogram to have solid borders but empty fill ( col ), to allow comparison with the underlying histograms. That is, the end result will be a series of panels, each with a different colored histogram, and each with the same extra outline histogram on top of the colored histogram. Here's something that I tried, but it just produces empty panels: foo

Create multiple lattice plots from a data table using lapply

丶灬走出姿态 提交于 2019-12-12 03:35:06
问题 I am trying to generate mean values by group for each of numerous variables (species) and then plot each of these separately. I have tried list and data table formats. The base plot function works in a for loop: library(data.table) for (i in 3:5) { # generate a list of mean value for the species in column number i temp <- v2[, lapply(.SD, mean), by="Season", .SDcols=i] # plot each col of the list as a scatterplot with main title = header of 2nd col plot(temp[[2]]~temp[[1]], main = colnames

How to make two small changes to a contourplot produced in lattice

落花浮王杯 提交于 2019-12-12 02:58:31
问题 I would like to make two cosmetic changes to a contourplot using the lattice function. These are to expand the size of the panel titles; add a title to the legend and key section, and shrink the colorkey object to fit this. A graphic showing what I mean is below, as on this occasion it will likely be more informative than the code. Solutions to either or both problems much appreciated. 来源: https://stackoverflow.com/questions/25400734/how-to-make-two-small-changes-to-a-contourplot-produced-in

Panel with different graphic packages figures

眉间皱痕 提交于 2019-12-12 02:49:34
问题 I hope the question is correctly stated. I would like to create, for didactic purposes, a knitr document where the outputs of the R base graphics system and the outputs of the Lattice package are compared in a panel. Consider a numeric vector: ```{r dataload} e2 <- c(72, 79, 81, 80, 63, 62, 89, 90, 50, 78, 87, 97, 55, 69, 97, 87, 88, 99, 76, 78, 65, 77, 88, 90, 81) ``` I tried to produce a panel with the following code: ```{r plots} par(mfrow = c(1,2)) #Set 1 row 2 columns panel hist(e2)

delimit sections in a lattice plot

喜你入骨 提交于 2019-12-12 01:23:55
问题 Consider a slice of a larger data.frame : dput(head(alele_freq_dev)) structure(list(chr = c("1A", "1A", "1A", "1A", "1A", "1A"), locus = c(1145442L, 1158042L, 1158055L, 1229616L, 1236254L, 1238114L), Trial = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("ES1-5", "ES6-13", "ES14- 26", "ES27-38", "SA1-13", "SA14-25"), class = "factor"), MAF = c(0.0780052257586973, 0.201305225758697, -0.101594774241303,-0.105094774241303, 0.0710052257586973, -0.101594774241303)), row.names = c(NA, 6L), class =

several ggplot2 plots on top on an image

爷,独闯天下 提交于 2019-12-11 20:56:58
问题 I have this nice custom plot function based on ggplot2 What I would now like to do, is to place several plots drawn with this function on top of a background image (loaded in as a png). I do not want to place the plots on a regular grid, but rather at select locations on the image. (An example of such a plot is can be seen on http://www.climatechange2013.org/images/figures/WGI_AR5_Fig10-21.jpg) It seems to me that I will need to have each of my plots drawn within a distinct environment, and a