Displaying 20 results from an estimated 10000 matches similar to: "ggplot2 / lattice"
2009 Nov 26
1
{ggplot2} Adding Mean to (grouped) Boxplot.
Hi R Users,
I am using following R code to plot a "grouped boxplot". I'm hoping if I can
add MEAN to these boxplots. Data is copied below and attached as text file.
install.packages("ggplot2")
library(ggplot2)
dta<-read.table("Sample.txt",header=T)
attach(dta)
p <- ggplot(dta, aes(factor(month), nail))
p + geom_boxplot(aes(fill = factor(trt)))
Data:
month
2010 May 24
1
lattice 'scales' option help
Hi All,
I'm trying to draw boxplots. I'm having a hard time to get "ticks labels" on
multiple panels using 'alternating' option.
# R Code:
# May not be the best example, please just look into 'scales' option
library(lattice)
data(OrchardSprays)
dta <- subset(OrchardSprays, OrchardSprays$rowpos %in% c(1,2,3))
# Original
# This works fine, as you can see
2011 Nov 08
2
compare linear regressions
Hi,
I'm trying to compare two linear regressions. I'm using the
following approach:
##################
xx<-1:100
df1 <- data.frame(x = xx, y = xx * 2 + 30 + rnorm(n=length(xx),sd=10), g = 1)
df2 <- data.frame(x = xx, y = xx * 4 + 9 + rnorm(n=length(xx),sd=10), g = 2)
dta <- rbind(df1, df2)
dta$g <- factor(dta$g)
2011 Apr 08
1
Adding text labels to lattice plots with multiple panels
Hi,
I am trying to add text to the bottom of a lattice bwplot with
multiple panels. I would like to add a label below each boxplot, but
the labels do not come from the data. I've tried the following, code:
f1 <- c(rep(c(rep("a", 3), rep("b", 3), rep("c", 3)), 2))
f2 <- c(rep("A", 9), rep("B", 9))
dv <- c(0.9, 0.8, 0.85, 0.6, 0.65,
2015 Jun 16
4
Ayuda boxplot ggplot2
Hola a todos
Me gustaría saber si me pueden ayudar con lo siguiente.
Realicé un Boxplot usando ggplot2 para visualizar el comportamiento de dos
variables. Visualmente no se notan las diferencias porque la gráfica de la
derecha (parásitos en el abdomen) llega hasta 20 en el eje y. ¿Cómo puedo
hacer para que las dos gráficas muestren la misma escala en el eje Y, es
decir, que las dos lleguen a 60?
2009 Jan 07
1
Problem with ggplot2 - facet_wrap and boxplot
Hello R users and Hadley,
Back again with a little problem in ggplot2 =o) (ggplot 0.8.1, R 2.8.0)
Here the problem :
library(ggplot2)
df <- data.frame(id = 1:100, x1 = c(rnorm(50), rnorm(50, 1)), x2 =
c(rnorm(50), rnorm(50, 1.5)), x3 = c(rnorm(50, 0.5), rnorm(50, 2.5)), group
= as.factor(rep(c("a", "b"), each = 50)))
df.melt <- melt(df, id = c("id",
2012 Oct 22
0
Lattice to ggplot2: Reference graphics across facets
Hi,
I'm playing with moving some of my lattice graphics into ggplot2, and I'd
like to ask how to achieve a couple of things, both of which are fully
illustrated in self-contained code (and mostly minimal, although that left
quite a bit) following this written description.
1. I quite often like to use a 'ghosted' reference across facets - for
example, in my example program below,
2013 Oct 12
2
Order of factors with facets in ggplot2
Hello,
I'd like to produce a ggplot where the order of factors within facets is
based on the average of another variable.
Here's a reproducible example. My problem is that the factors are ordered
similarly in both facets. I would like to have, within each facet of `f1',
boxplots for 'x' within each factor `f2', where the boxplots are ordered
based on the average of x
2008 May 27
1
label outliers in geom_boxplot (ggplot2)
Dear List and Hadley,
I would like to have a boxplot with ggplot2 and have the outlier values
labelled with their "name" attribute. So I did
> library(ggplot2)
> dat=data.frame(num=rep(1,20), val=c(runif(18),3,3.5),
name=letters[1:20])
> p=ggplot(dat, aes(y=val, x=num))+geom_boxplot(outlier.size=4,
outlier.colour="green")
>
2011 Oct 04
1
ggplot2: changing default colors of boxplot
Hi,
I wanted to change the default colors appearing in boxplot. For example, the
following code (from the package/documentation):
===========
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(aes(fill = factor(am)))
===========
Gives the default colors. What do I need to do to modify this so that:
1. Change the colors from green and red to blue and black
2. Only
2011 Aug 04
1
labelling a stacked barchart (lattice)
All:
Below is my code for creating a basic horizontal, stacked barchart. I'd like to label the plot in two ways: 1) place the x values in each piece and 2) place the y values above each piece (angled). I'm currently using lattice, but I'm open to suggestions using ggplot2.
Questions:
1. Can this be done?...I assume yes. So, what are the best options/functions for doing this.
2.
2012 Jul 02
5
ggplot: dodge positions
Dear all,
I want to get a series of boxplots (grouped by two factors) and I want to overlay the original observations and the following code does almost what I want:
library(ggplot)
ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y = runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4)))
ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point()
Yet the position of the points
2008 Feb 27
1
ggplot2 boxplot confusion
Ultimately my aim is to get a plot of density faceted by 2 factors with a
horizontal boxplot overlaid on each density plot in the grid to indicate
summary stats. So I've been experimenting with creating boxplots and density
plots. Here's some representative data.
series = c('C2','C4','C8','C10','C15','C20')
ids =
2010 Jun 13
1
add only selected labels using thigmophobe
hi,
I am trying to label data points within a scatter plot using thigmophobe.
While the data set consists of about 3000 points I only would like to label
a subset of these points.
I read the x and y coordinates in from a txt file and define them as:
MLPM1<-log2(Ratio.M.L.G2.PM)
HLG2<-log2(Ratio.H.L..G2.PM)
the names and a corresponding ID are read in from the same txt file as:
2008 Jun 16
2
Lattice: Superpose bwplot and dotplot [newbie question]
Hello everyone
I have dataset containing a monetary value (ABS) and two factors (Fct,
Group). I am able to create useful using:
bwplot(ABS~Group|Fct)
and
dotplot(ABS~Group|Fct)
Question: What do I have to do to overlay the dotplot with the bwplot (same
data set)?
I've found a couple of posts that hinted at the possibility of doing that,
and checked the panel.superpose() help, but the info
2009 Nov 26
3
barchart() {Lattice} help.
Hi R Users,
I'm trying to plot a stacked barplot. Here is data:
Sample Col1 Col2 Col3
Row1 -2 4 -1
Row2 3 -2 4
Row3 3 5 -2
Row4 4 1 -1
I'm using following R code:
library(lattice)
dta<-read.table("data.txt", header=TRUE, row.names="Sample")
barchart(data.matrix(dta),
horizontal=FALSE,
stack=TRUE,
col=2:4,
2011 Jun 10
1
Double x grid in ggplot2
I am trying to overlay raw data with a boxplot as follows:
pp = qplot(factor(time, levels=0:60, ordered=TRUE),
error, data=dfsub, size=I(1), main =" title", ylab="Error
(min)",
xlab="Time before ON (min)", alpha=I(1/10),
ylim=c(-30,40), geom="jitter") +
facet_wrap(~ runway, ncol=2) +
2009 Mar 05
1
is there any option like cex.axis in ggplot2?
Dear list,
I made boxplots using ggplot and want to control for x- and yaxis. Using "plot" I can do it by setting cex.axis equally to any size but can't figure out how to do it with ggplot.
ggplot(dat, aes(x = factor(time), y = volume)) + opts(axis.title.x=theme_text(size=8),axis.title.y=theme_text(size=8)) +
geom_boxplot() + geom_jitter(aes(colour = id))+labs(x =
2013 May 03
1
print multiple plots to jpeg, one lattice and one ggplot2
hello everybody,
I want to print two plots in one png file, I tried several options but i
didn't succeed
the first plot (bwplot) print to the defined position, but the second
(ggplot) doesn't
Any idea?
Thanks a lot
Christophe
# Example:
#-------------------------------------
library(ggplot2)
library(lattice)
library(grid)
one <- bwplot(decrease ~ treatment, OrchardSprays, groups
2009 Dec 29
1
ggplot2, building a simple formula interface
I?m trying to build a simple formula interface to work with a function using
ggplot2. The following scheme ?works? up until the plot(p) request, at which
point there are complaints about xlim?s and a blank graphics window.
Looking at str(p) I do see the limits are NULL, plus layer 1 claims to have
an empty data frame (but df is reproduced correctly). I'm sure I'm missing
something really