Re: [R] the bar width of barchart plot in lattice package
probably yes. I plotted each row individually instead. Thanks On Fri, Apr 23, 2010 at 11:14 AM, Deepayan Sarkar wrote: > On Wed, Apr 21, 2010 at 8:55 PM, David Winsemius > wrote: > > > > On Apr 21, 2010, at 9:51 PM, zhenjiang xu wrote: > > > >> I tried that. It seems the bar width is already maximized, although > there > >> is a lot of space between groups of bars. Thank you anyway. > > > > I apologize. It was reproducible code. I missed the "values" assignment. > > There is also a box.width argument which does affect how the plot gets > > drawn, but the effects do not appear salutory. It appears that the > alignment > > of the bars gets shifted relative to the labels. The barchart function > > cannot seem to deal with the completity of the 2 * 5 factor crossed with > a > > c(3,3,4) factor. On the other hand that problem seems to be present in > the > > original plot as well. Maybe you should re-think the structure of the > data? > > The problem is that levels is nested within factors: > > > xtabs(~levels + factors, a) > factors > levels Cycles MaxPairs Order > Cycle 1 100 0 > Cycle 2 100 0 > Cycle 3 100 0 > Cycle 4 100 0 > Order 10010 > Order 20010 > Order 30010 > MaxPairs = 20 0 10 0 > MaxPairs = Average Length 0 10 0 > MaxPairs = 500 0 10 0 > > I can't think of a meaningful design that would give the desired result > here. > > -Deepayan > -- Best, Zhenjiang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the bar width of barchart plot in lattice package
On Wed, Apr 21, 2010 at 8:55 PM, David Winsemius wrote: > > On Apr 21, 2010, at 9:51 PM, zhenjiang xu wrote: > >> I tried that. It seems the bar width is already maximized, although there >> is a lot of space between groups of bars. Thank you anyway. > > I apologize. It was reproducible code. I missed the "values" assignment. > There is also a box.width argument which does affect how the plot gets > drawn, but the effects do not appear salutory. It appears that the alignment > of the bars gets shifted relative to the labels. The barchart function > cannot seem to deal with the completity of the 2 * 5 factor crossed with a > c(3,3,4) factor. On the other hand that problem seems to be present in the > original plot as well. Maybe you should re-think the structure of the data? The problem is that levels is nested within factors: > xtabs(~levels + factors, a) factors levels Cycles MaxPairs Order Cycle 1 100 0 Cycle 2 100 0 Cycle 3 100 0 Cycle 4 100 0 Order 10010 Order 20010 Order 30010 MaxPairs = 20 0 10 0 MaxPairs = Average Length 0 10 0 MaxPairs = 500 0 10 0 I can't think of a meaningful design that would give the desired result here. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the bar width of barchart plot in lattice package
On Apr 21, 2010, at 9:51 PM, zhenjiang xu wrote: I tried that. It seems the bar width is already maximized, although there is a lot of space between groups of bars. Thank you anyway. I apologize. It was reproducible code. I missed the "values" assignment. There is also a box.width argument which does affect how the plot gets drawn, but the effects do not appear salutory. It appears that the alignment of the bars gets shifted relative to the labels. The barchart function cannot seem to deal with the completity of the 2 * 5 factor crossed with a c(3,3,4) factor. On the other hand that problem seems to be present in the original plot as well. Maybe you should re-think the structure of the data? Compare: bc.factors <- barchart(values ~ sequences | scores * factors , data = a, groups = levels, layout = c(2,3), box.ratio=1, box.width=1.5, between = list(y=0.5), clip = list(strip = 'off'), par.strip.text = list(cex=0.7), par.settings = list(fontsize=list(text=8)), auto.key = list(rectangles = TRUE, space = 'right', columns = 1), draw.key = TRUE, scales = list(x = list(rot = 45))) -- David. On Tue, Apr 20, 2010 at 10:16 AM, David Winsemius > wrote: On Apr 20, 2010, at 9:46 AM, zhenjiang xu wrote: Dear R users, I am trying to use the following code to make a barchar plot. The bars in the plot turn out to be a little narrow. Is there any way to modify the width of the bars? Thank you! library(lattice) scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', 'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces griseus'), length = 100) levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3', 'Cycle 4', 'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average Length', 'MaxPairs = 500')) factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30)) values = rnorm(100) # this is toy data a = data.frame(values, scores, sequences, levels, factors) bc.factors = barchart(values ~ sequences | scores * factors , data = a, groups = levels, layout = c(2,3), between = list(y=0.5), clip = list(strip = 'off'), par.strip.text = list(cex=0.7), par.settings = list(fontsize=list(text=8)), auto.key = list(rectangles = TRUE, space = 'right', columns = 1), draw.key = TRUE, scales = list(x = list(rot = 45))) ?barchart Looking at the arguments to barchart in the help page I would have guessed that box.ratio would do what you want. Since that is clearly not reproducible code , (in the absence of test dataset of the appropriate structure) I suppose guessing will remain the level of my knowledge in this instance. -- Best, Zhenjiang David Winsemius, MD West Hartford, CT -- Best, Zhenjiang David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the bar width of barchart plot in lattice package
I tried that. It seems the bar width is already maximized, although there is a lot of space between groups of bars. Thank you anyway. On Tue, Apr 20, 2010 at 10:16 AM, David Winsemius wrote: > > On Apr 20, 2010, at 9:46 AM, zhenjiang xu wrote: > > Dear R users, >> >> I am trying to use the following code to make a barchar plot. The bars in >> the plot turn out to be a little narrow. Is there any way to modify the >> width of the bars? Thank you! >> >> library(lattice) >> scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) >> sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', >> 'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces >> griseus'), length = 100) >> levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3', 'Cycle 4', >> 'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average >> Length', 'MaxPairs = 500')) >> factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30)) >> values = rnorm(100) # this is toy data >> a = data.frame(values, scores, sequences, levels, factors) >> bc.factors = >> barchart(values ~ sequences | scores * factors , data = a, >> groups = levels, >> layout = c(2,3), >> between = list(y=0.5), >> clip = list(strip = 'off'), >> par.strip.text = list(cex=0.7), >> par.settings = list(fontsize=list(text=8)), >> auto.key = list(rectangles = TRUE, space = 'right', columns = 1), >> draw.key = TRUE, >> scales = list(x = list(rot = 45))) >> >> > ?barchart > > Looking at the arguments to barchart in the help page I would have guessed > that box.ratio would do what you want. Since that is clearly not > reproducible code , (in the absence of test dataset of the appropriate > structure) I suppose guessing will remain the level of my knowledge in this > instance. > > > -- >> Best, >> Zhenjiang >> > > David Winsemius, MD > West Hartford, CT > > -- Best, Zhenjiang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] the bar width of barchart plot in lattice package
On Apr 20, 2010, at 9:46 AM, zhenjiang xu wrote: Dear R users, I am trying to use the following code to make a barchar plot. The bars in the plot turn out to be a little narrow. Is there any way to modify the width of the bars? Thank you! library(lattice) scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', 'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces griseus'), length = 100) levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3', 'Cycle 4', 'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average Length', 'MaxPairs = 500')) factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30)) values = rnorm(100) # this is toy data a = data.frame(values, scores, sequences, levels, factors) bc.factors = barchart(values ~ sequences | scores * factors , data = a, groups = levels, layout = c(2,3), between = list(y=0.5), clip = list(strip = 'off'), par.strip.text = list(cex=0.7), par.settings = list(fontsize=list(text=8)), auto.key = list(rectangles = TRUE, space = 'right', columns = 1), draw.key = TRUE, scales = list(x = list(rot = 45))) ?barchart Looking at the arguments to barchart in the help page I would have guessed that box.ratio would do what you want. Since that is clearly not reproducible code , (in the absence of test dataset of the appropriate structure) I suppose guessing will remain the level of my knowledge in this instance. -- Best, Zhenjiang David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] the bar width of barchart plot in lattice package
Dear R users, I am trying to use the following code to make a barchar plot. The bars in the plot turn out to be a little narrow. Is there any way to modify the width of the bars? Thank you! library(lattice) scores = gl(2, 5, label=c('Sensitivity', 'PPV'), length = 100) sequences = gl(5, 1, label=c('Lemna minor', 'Dugesia japonica A', 'Gymnosporangium sabinae', 'Hymeniacidon sanguinea', 'Streptomyces griseus'), length = 100) levels = gl(10, 10, label = c('Cycle 1', 'Cycle 2', 'Cycle 3', 'Cycle 4', 'Order 1', 'Order 2', 'Order 3', 'MaxPairs = 20', 'MaxPairs = Average Length', 'MaxPairs = 500')) factors = c(rep('Cycles', 40), rep('Order', 30), rep('MaxPairs', 30)) values = rnorm(100) # this is toy data a = data.frame(values, scores, sequences, levels, factors) bc.factors = barchart(values ~ sequences | scores * factors , data = a, groups = levels, layout = c(2,3), between = list(y=0.5), clip = list(strip = 'off'), par.strip.text = list(cex=0.7), par.settings = list(fontsize=list(text=8)), auto.key = list(rectangles = TRUE, space = 'right', columns = 1), draw.key = TRUE, scales = list(x = list(rot = 45))) -- Best, Zhenjiang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.