lattice

R: Lattice How to remove white space between bars and x axis?

。_饼干妹妹 提交于 2019-12-11 06:50:38
问题 I am new to R and am using lattice to create a clustered bar graph. I wrote the following code. nature <- read.table(text = "Nature_of_recreation, Familiarity_with_the_partner, Count Danced, Not familiar at all, 21 Danced, Not very familiar, 22 Danced, Very familiar, 22 Sketched, Not familiar at all, 6 Sketched, Not very familiar, 17 Sketched, Very familiar, 16 Dined, Not familiar at all, 16 Dined, Not very familiar, 14 Dined, Very familiar, 10 Swimmed, Not familiar at all, 6 Swimmed, Not

multiarea chart in lattice

筅森魡賤 提交于 2019-12-11 06:14:44
问题 I am pushing lattice to its limits. Consider this example tibble(time = c(ymd('2019-01-01'), ymd('2019-01-02'), ymd('2019-01-03'), ymd('2019-01-01'), ymd('2019-01-02'), ymd('2019-01-03'), ymd('2019-01-01'), ymd('2019-01-02'), ymd('2019-01-03')), variable = c('a','a','a','b','b','b', 'c','c','c'), value = c(1,2,3,0,0,2,2,4,3)) %>% ggplot(aes(x = time, y = value, fill = variable)) + geom_area() Using the nice solution in how to create a stacked area chart in lattice? does not work here, perhaps

lattice graphics in a R widget

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:38:10
问题 Using the gWidgets package I have made a R widget that shows a lattice graphic when the user click on a button. The function producing the graphic ( fgraph() below) runs well outside the widget. However the graphic at the topleft corner does not appear in the widget. Here is a reproducible code: library(lattice) sims <- data.frame( y=rnorm(8), A=factor(c(1,1,1,1,2,2,2,2)), B=factor(c(1,1,2,2,1,1,2,2)), C=factor(c(1,2,1,2,1,2,1,2)) ) fgraph <- function(sims){ plot( dotplot(y ~ A | B+C , data =

exact positioning of plots with grid.layout

偶尔善良 提交于 2019-12-11 04:58:11
问题 I have two lattice plots. I need to position one above the other, and I need exactly .5" of vertical space between them. My thought is to use grid.layout to specify a three-row layout, with the middle row being exactly .5" high. Then I can print one plot to the top row and the other plot to the bottom row. It's almost working. The problem is that I can't get the middle row to be exactly .5" high. Here's a minimal example: pdf(file='example.pdf', height=12) # Create layout and viewports

Hide top x-axis in doubleYScale plot in R

三世轮回 提交于 2019-12-11 02:47:29
问题 I'm plotting two xyplots with a doubleYScale plot. I would like to hide the top x-axis, but everything I tried so far either does nothing or hides all axes. Is this even possible? library(lattice) library(latticeExtra) x<-seq(1:10) y<-x^2 y2<-x*2 plot1<-xyplot(y~x, col="black", type="l", ylab="Label1", xlab="") plot2<-xyplot(y2~x, col="red", type="l", ylab="Label2", xlab="", scales=list(y=list(col="red"))) doubleYScale(plot1, plot2, add.axis=TRUE, add.ylab2 = TRUE, scales=list(x=list(draw

r lattice - wrong position of horizontal abline after bwplot

醉酒当歌 提交于 2019-12-11 02:33:32
问题 I can do this without problems: boxplot(coef ~ habitat, data = res) abline(h = 0, col = "green") But when I use lattice, the horizontal line is misplaced: bwplot(coef ~ habitat, data = res) abline(h = 0, col = "green") I tried to use panel.abline instead but that places the green line on top of the picture. 回答1: Use a panel function; order the contained functions in the order you'd like parts added; make use of ... to avoid having to know / manage all parameters to the panel function bwplot

Removing per-panel unused factors in a bar chart

試著忘記壹切 提交于 2019-12-10 23:39:25
问题 I am trying to make a plot using barchart from lattice, but I am having some issues with unused factors for a given panel. I have tried using drop.unused.levels but it seems it only drops factors when they are not used in any panel. This is the data frame that I am using: dm <- structure(list(Benchmark = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 4L, 5L, 6L, 7L), class = "factor", .Label = c("416

R: How to Parallelize multi-panel plotting with lattice in R 3.2.1?

十年热恋 提交于 2019-12-10 22:18:48
问题 I am new to R programming and wanted to know how to run in parallel plot on 12 trellis objects made with lattice package. Basically, after a lot of pre-processing steps, I have the following commands: plot(adhd_plot, split = c(1,1,4,3)) #plot adhd trellis object at 1,1 in a grid of 4 by 3 i.e 4 COLUMNS x 3 ROWS plot(bpd_plot, split = c(2,1,4,3), newpage = F) #plot bpd trellis object in 2nd Column in a grid of 4colx3row plot(bmi_plot, split = c(3,1,4,3), newpage = F) plot(dbp_plot, split = c(4

R lattice 3d plot: ticks disappear when changing panel border thickness

眉间皱痕 提交于 2019-12-10 19:29:20
问题 The following code using cloud produces a plot with tick marks as expected: require(lattice) cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris, scales = list(arrows=F)) When the panel border thickness is changed using axis.line within the par.setting argument, the border thickness gets changed but the tick marks disappear, whether or not the tck argument is invoked within scales : cloud(Sepal.Length ~ Petal.Length * Petal.Width, data = iris, scales = list(arrows=F, tck=1), par

Using dataframe column names as chart label in Apply

萝らか妹 提交于 2019-12-10 18:15:29
问题 I want to create a series of x-y scatter charts, where y is always the same variable and x are the variables I want to check if they are correlated with. As an example lets use the mtcars dataset. I am relatively new to R but getting better. The code below works, the list charts contains all the charts, except that the X axis shows as "x", and I want it to be the name of the variable. I tried numerous combinations of xlab= and I do not seem to get it if I use names(data) I see the names I