lattice

How to change Lattice graphics default groups colors?

痞子三分冷 提交于 2019-12-08 11:09:30
问题 When using groups , Lattice gives each group a different color. Example: df <- data.frame(x=1:56, y=rnorm(56), class=1:14) # create some data xyplot(y ~ x, groups=class, data=df, type="l", auto.key=list(space="right")) However, by default Lattice only uses seven colors, as running the example above will show. If you have more than seven groups, Lattice cycles through the colors again in order, causing data from distinct groups to have the same color. I learned from another Stackoverflow

How do I plot a number of categorical variables on a graph in R?

时光怂恿深爱的人放手 提交于 2019-12-08 08:57:43
问题 I have about 10 categorical variables - pay1, pay2, ... , pay10 each having values either 'Yes' or 'No'. I would like to plot the count of each of these variables on a graph. For example - bar1 on the chart should refer to the variable 'pay1' reflecting the total number of observations divided between 'Yes' and 'No'('Yes' on top of 'No' or vice versa) This scheme should be consistent with all the 10 variables on the chart. If I am able to display the percentage of 'Yes' and 'No' for each bar,

How to add labels as percentages to the lattice stacked bar charts in R?

流过昼夜 提交于 2019-12-08 06:49:41
问题 I have created some stacked bar charts with the likert function from the HH package, that uses lattice . Now I want to add labels represented as percentages inside to each segment of the charts, or, better, only to that segments that have a sufficient width for that. How to do this? I mention that my data are represented as frequencies, not as percentages. My data : ssb <- structure(list(`Strongly Disagree` = c(2L, 1L), `Moderate Disagree` = 1:2, `Slightly Disagree` = c(3L, 1L), `Slightly

how to display a projected map on an R::lattice::layerplot?

时间秒杀一切 提交于 2019-12-08 06:01:37
问题 summary: I can display a lon-lat map on a lattice::layerplot , and I can display a Lambert conformal conic (LCC) map on a spam::image . How to display an LCC map on a lattice::layerplot ? Examples of how not to do it follow--assistance in fixing is appreciated (or even just debugging). details: I've been using trellis graphics (via latticeExtra and rasterVis ) successfully to display unprojected lon-lat global atmospheric data, which works well enough (though I am definitely intrigued by

Add a line to coplot {graphics}, classic approaches don't work

会有一股神秘感。 提交于 2019-12-08 05:29:59
问题 I found coplot {graphics} very useful for my plots. However, I would like to include there not only one line, but add there one another. For basic graphic I just need to add = TRUE to add another line, or tu use plot(..) and lines(..). For {lattice} I can save my plots as objects a<-xyplot(..) b<-xyplot(..) and display it simply by a + as.layer(b) . No one of these approaches works for coplot() , apparently because creating objects as a<-coplot() doesn't produce trellis graphic but NULL

How to add labels as percentages to the lattice stacked bar charts in R?

人盡茶涼 提交于 2019-12-08 05:03:28
I have created some stacked bar charts with the likert function from the HH package, that uses lattice . Now I want to add labels represented as percentages inside to each segment of the charts, or, better, only to that segments that have a sufficient width for that. How to do this? I mention that my data are represented as frequencies, not as percentages. My data : ssb <- structure(list(`Strongly Disagree` = c(2L, 1L), `Moderate Disagree` = 1:2, `Slightly Disagree` = c(3L, 1L), `Slightly Agree` = c(1L, 5L), `Moderate Agree` = 4:5, `Strongly Agree` = c(9L, 6L), Grup = c("Experimental grup",

Saving Lattice Plots with RInside and Rcpp

♀尐吖头ヾ 提交于 2019-12-08 04:58:51
问题 I am trying to build an R application in C++ using RInside. I wanted to save the plots as images in specified directory using codes, png(filename = "filename", width = 600, height = 400) xyplot(data ~ year | segment, data = dataset, layout = c(1,3), type = c("l", "p"), ylab = "Y Label", xlab = "X Label", main = "Title of the Plot") dev.off() It creates a png file in the specified directory if directly run from R. But using C++ calls from RInside, I was not able to reproduce the same result. (

Plotting a rather complex chart using R and axis break()

冷暖自知 提交于 2019-12-08 04:54:53
问题 Hi R users and programmers, I have a data set consisting of 4563 amino acids of a protein. Using three different treatments and two different oxidants, amino acids in this protein were oxidized. I would like to plot the position of those oxidations in a chart based on the treatment. Different line size will represent varying oxidant concentration and line type (dashed and solid) will represent different types of oxidant. I would like to break the axis at each 1000 amino acid. I have created a

how to display a projected map on an R::lattice::layerplot?

半城伤御伤魂 提交于 2019-12-07 23:40:31
summary: I can display a lon-lat map on a lattice::layerplot , and I can display a Lambert conformal conic (LCC) map on a spam::image . How to display an LCC map on a lattice::layerplot ? Examples of how not to do it follow--assistance in fixing is appreciated (or even just debugging). details: I've been using trellis graphics (via latticeExtra and rasterVis ) successfully to display unprojected lon-lat global atmospheric data, which works well enough (though I am definitely intrigued by ggplot / ggmap ). Particularly, I am able to overlay those plots with maps, which is essential for the sort

R Lattice / LatticeExtra combine Barplot with Textplot - Labels not properly displayed

落花浮王杯 提交于 2019-12-07 22:59:51
问题 Goal: I want to create a 3D barplot (as shown below) showing value z for each combination of methods "X1"-"X4" and "Y1"-"Y4", where the labels shall correspond to the rank of the z variable. Problem: As you can see below, the labels in the image do not match the ranking values of z (rank 1 = lowest value of z, rank 16 = highest value of z). For instance, combination "X1-Y3" should have the index 1 instead of 8, because it has the lowest z-value. Hence, how can I fix this? Image-Output (with