Displaying 20 results from an estimated 1000 matches similar to: "ggplot2 - facetting"
2008 Mar 23
2
ggplot2 - legend for fill coulours
Dear All,
I am trying to build a stacked bar plot, where I define the colours to use.
I have asked this before, and I was using a solution in
http://thread.gmane.org/gmane.comp.lang.r.general/100649/focus=100673
(thanks, Thierry).
However, it looks this works only when the data are in the sequence
of the levels in the factor defining the fill colours. When the
sequence is different, the
2007 Dec 17
1
ggplot-How to define fill colours?
Dear R's (most likely Hadley),
I want to build a stacked bar plot where I would like to define which
colours will be used for each of the groups. However, I do not seem
to find a way to do this, even if I've been looking over many places.
I have tried several variations, and my final try was this code, but
I still do not manage to get the colours as I pre-define. Any hints
about how
2005 Sep 14
3
Effects.Scale and form input elements
is it possible to use Effects.Scale to make a set of form input
elements appear in a ''slide out'' effect? I''m trying to build a
control with a button which, when clicked, will cause a row of form
inputs to appear. I can do this with Effects.Appear, but what I
really wanted was for the inputs to appear to ''slide out'' from the
button.
What I
2000 Jul 07
2
Question of programming style
This is really a question of how to program this *BETTER*. It works as I have
done it, but is quite ugly.
I want to do a 3d scatterplot of the upper triangle of a matrix, where the
z-values are the values in the matrix, and the row and column indices are the y-
and x-values. The complete (11 by 11) matrix is mmtop94.2. Here is my awkward
code:
mmtop94.2[lower.tri(mmtop94.2)] <- NA
# Here i
2009 Oct 02
1
ggplot2: proper use of facet_grid inside a function
Hello Again R Folk:
I have found items about this in the archives, but I?m still not getting
it right. I want to use ggplot2 with facet_grid inside a function with
user specified variables, for instance:
p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
fac2)
Where data, fac1, fac2 and res are arguments to the function. I have
tried
p <- ggplot(data,
2012 Feb 24
1
Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions
I am plotting three Pearson Type IV distributions. It looks like I have to plot the distribution with the highest value of y and then use lines() to add the two distributions that are shorter / have lower max values of y. The following code figures out which distribution has the max y value, plots it first and then uses lines for the other two distributions with a series of three if statements.
2009 Jun 08
1
Looking for easy way to normalize data by groups
Hi,
i do have a dataframe representing data from a repeated experiment. PID
is a subject identifier, Time are timepoints in an experiment which was
repeated twice. For each subject and all three timepoints there are 2
sets of four values.
df <- data.frame(PID = c(rep("A", 12), rep("B", 12), rep("C", 12)),
Time = rep(c(0, 0, 0, 0, 30, 30, 30,
2005 Jun 24
3
flashing divs in IE with use of BlindUp and BlindDown
I''m having an issue with flashing divs in IE (firefox is fine and the
only other browser I''ve used)
My scenario is as follows. I have 2 divs (initially hidden) and using
the BlindDown and BlindUp functions (possibly others) the divs flash
when starting to roll down in BlindDown (due to the Element.show call)
and also at the end of the BlindUp call (due to the Element.hide call)
2010 Nov 09
1
ggplot2: facet_grid with different vertical lines on each facet
Hello,
I am plotting many histograms together using facet_grid in ggplot2. However,
I want to then add a vertical line to each histogram, or facet, each of
which vertical lines are at different x-values.
The following example adds all vertical lines to each facet:
ggplot(data,aes(values)) + geom_histogram() + facet_grid(.~variable) +
geom_vline(xintercept=c(5,10,15))
How can I add a vertical
2011 Jul 24
1
barplot colors
Hi,
In barplot(height, col = ...), the col = vector recycles so that the
same colors are used for each bar. I would like to use different colors
in different bars (corresponding to another piece of information, here,
the region of the country being represented).
For example,
x = matrix(c(5,2,3,1),nrow=2)
barplot(x,col=1:4)
will draw two bars with two segments each, but each colored red and
2005 Oct 18
3
Blind... Effects
Hello,
is there a way to basically achieve a BlindLeft and BlindRight effect and if
yes, how would I do that?
Thank you in advance for your help.
_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
2009 Feb 11
2
Label bars in a faceted bar plot in ggplot2
Hi List,
I am running R 2.8.0 on a Windows XP machine, running ggplot2 version 0.8.1
I want to label the bars in a faceted grid barplot. Reproducible R
code is given below:
#### reproducible facet barplot #####
library(ggplot2)
# Dataset from which to create the barplot
ml <- rep(1:10,2)
vals <- rnorm(20,mean = 10, sd=1)
type <- c(rep("MAPE",10),rep("AIC",10))
2008 Nov 17
1
ggplot2: can one have separate ylim for each facet?
In lattice
#toy data
library(ggplot2)
library(lattice)
x <- rnorm(100)
y <- rnorm(100)
k <- sample(c("Weak","Strong"),100,replace=T)
j <- sample(c("Tall","Short"),100,replace=T)
w <- data.frame(x,y,j,k)
xyplot(y~x|j+k,scales=list(y=list(relation="free")))
will give you a scale in each subplot with a range equal to the range
of y
2010 Sep 11
1
Setting scales for ggplot2 with facets
Faceting in ggplot2 seems to permit different scales for different
facets, but I fail
to see how one could control ylim and xlim ranges for each facet
separately.
For instance, I would like to set the ylim = c(0,10) for facet "A"
and ylim = c(42,102) for facet "B". Since the data is out of these
ranges,
setting facet_grid(factor ~ ., scales = "free_y") does not
2011 May 18
1
Changing order of facet grid in ggplot2
Hi I am running the following code:
sym <- c(sym1,sym2,sym4)
lifedxm <- c("O-BD","O-WELL","O-UNI")
life <- c(lifedxm,lifedxm,lifedxm)
tp <- c("TP-ANY","TP-ANY", "TP-ANY", "TP-SUB", "TP-SUB", "TP-SUB", "TP-CLIN"
, "TP-CLIN", "TP-CLIN")
data <-
2013 Apr 14
1
Problem plotting continuous and discrete series in ggplot with facet
I have data that plots over time with four different variables. I would
like to combine them in one plot using facet_grid, where each variable gets
its own sub-plot. The following code resembles my data
require(ggplot2)
require(reshape2)
subm <- melt(economics, id='date', c('psavert','uempmed','unemploy'))
mcsm <- melt(data.frame(date=economics$date,
2012 Mar 12
1
Faceted bar plot shows wrong counts (ggplot2)
I have encountered a problem with faceted bar plots. I have tried to
create something like the example explained in the ggplot2 book (see pp.
126-128):
library(ggplot2)
mpg4 <- subset(mpg, manufacturer %in%
c("audi", "volkswagen", "jeep"))
mpg4$manufacturer <- as.character(mpg4$manufacturer)
mpg4$model <- as.character(mpg4$model)
base <-
2007 Nov 08
1
ggplot2 facets as rows and columns
Does anyone (Hadley??) know if there's a straightforward
way in ggplot2 to get data divided by a single factor to
plot as a rectangular grid of subplots? So far I've only
been able to get such data plotted as a single row or
single column of skinny subplots. The code below gives
an example implemented with lattice, and my best
attempt in ggplot2
cheers
Ben Bolker
------------
g=
2010 May 09
1
Is it possible to rearrange the facets in ggplot while keeping everything else the same?
Hello,
First, ggplot2 is great!
Second, sorry for the basic nature of my question.
I have data in the form of a melt table like this:
Subject Day Ab Variable Value
1 1 Yes A 3
1 3 Yes A 5
1 5 Yes A 7
2 1 No A 2
2 3 No A 4
2 5 No A 6
3 1 Yes A 1
3 3 Yes A 3
3 5 Yes A 5
4 1 No A 4
4 3 No A 6
4 5 No A 8
1 1 Yes B 3
1 3 Yes B 5
1 5 Yes B 7
2 1 No B 2
2 3 No B 4
2 5 No B 6
3 1 Yes B 1
3 3 Yes B 3
3 5
2008 Sep 28
1
reshape package does not recognize second id variable
I am trying to use the reshape package for the first time. I have two
waves of a survey, so the id variables include a subject
identification number and a variable denoting the wave of the survey.
I used the following arguments:
library(reshape)
svy.melt <- melt(svy, id=c("id", "WAVE"))
svy.wide <- cast(svy.melt, id ~ WAVE + ...)
and got the following error: