Displaying 20 results from an estimated 5000 matches similar to: "Different axis limits for each facet in ggplot2"
2007 Jul 13
1
Choosing the number of colour breaks in ggplot2
A seemingly simple problem has me stumped. Is it possible to choose the
number of colour breaks for a gradient scale in the current version of
ggplot2?
Here is a simple example:
---------------------------------------------
x=-10:10
y=-10:10
dat=expand.grid(x=x,y=y)
dat$z=dat$x^2+dat$y^2-100
ggplot(dat, mapping=aes(x=x, y=y, fill=z)) +
geom_tile() + scale_fill_gradient2()
2008 Feb 27
1
how to specify ggplot2 facet plot order
Hi, new to R and ggplot2. I've been trying to get a facet plot in which the
order of the facets is as I require, rather than ordered numerically,
alphabetically, by Roman numerals, mean (answers to these were posted here
after much searching). Here's some test code to demonstrate what I get.
series = c('C2','C4','C8','C10','C15','C20')
ids =
2006 Sep 12
1
lattice cloud and conditional axis limits
I'm using the 'cloud' function in the 'lattice' package to produce
multi-panel 3D scatter plots. The range of the values used vary much
between each panel (especially on the z axis), so I wish the axis limits
to be calculated based on the (conditional) data.
Here's a minimal example:
library(lattice)
z=1:200
x=runif(200)
y=runif(200)
s=factor(rep(c(1,2),each=100))
2009 Aug 11
1
ggplot2: override facet names in facet_wrap?
just a quick question (to which I suspect the answer is "no"):
does anyone know if, in the ggplot2 package, there's a way to
override the default names of the facets in facet_wrap (which
correspond to the levels of the factor used to facet)? I know
that I go back and change the levels of the factor, but it would
be convenient to be able to supply a vector of level names at
the time
2009 Oct 19
2
Possible bug in plot.POSIXct regarding x axis
I believe I have found a bug (or at least a misfeature) in plot.POSIXct.
See the following example code.
set.seed(1)
x=seq(1,1e8,length=100)+round(runif(100)*1e8)
y=as.POSIXct(x,origin="2001-01-01")
plot(y)
This plots some random (date)times against their indices. The y axis
correctly shows appropriate values (years), but the x axis contains the
single number '59:58' in the
2008 Jun 17
1
ggplot facet spacing, wrapping
I'm running into some problems with the spacing of some faceted ggplot plots.
I have a number of time series faceted to be one above another, but the
scale labels of the y axes all clobber each other at the bottom/top of each.
for example, try:
qplot(x, y, data = data.frame(x = 1:10, y = 1:10, size = 1:10), facets =
size ~ ., size = size) + scale_x_continuous(breaks = 1:10) +
2013 Feb 08
3
Border width on symbols plotted with the lattice package
Dear list members,
I can't figure out how get 'xyplot' or 'dotplot' in the 'lattice'
package to respect the 'lwd' value for specifying the border with for
*symbols* (for lines it works fine). Example:
-----
# Base graphics works fine (gives a 'fat? circle)
plot(5, cex=10, pch=21, lwd=10)
# But 'xyplot' or 'dotplot' doesn't
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
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 Apr 22
2
Getting rid of borders on semi-transparent plotting symbols
R version 2.7.0 RC (2008-04-20 r45403)
When using semi-transparent filled plotting symbols, the border of the
symbol has a different (darker) colour than the interior:
plot(0, 0, pch=19, col="#FF000022")
(Saving this as a PDF and looking at it magnified may make it easier to
see.)
This is pretty annoying, since when plotting partially overlapping
points, the border colour dominates,
2011 Feb 02
3
Applying multiple functions to one object
Dear list members,
I recall seeing a convenience function for applying multiple functions to
one object (i.e., almost the opposite of 'mapply?) somewhere.
Example: If the function was named ?fun? the output of
fun(3.14, mode, typeof, class)
would be identical to the output of
c(mode(3.14), typeof(3.14), class(3.14))
Is my memory failing me, or does such a function already exists in a
2009 Oct 30
1
Applying a function on n nearest neighbours
I'm having a problem where I have to apply a function to a subset of a
variable, where the subset is defined by the n nearest neighbours of a
second variable.
Here's an example applied to the 'iris' dataset:
$ head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4
2009 Nov 25
1
Kerning issues with CairoPDF
Dear list members
I'm using CairoPDF to generate PDF (because of its font embedding and
support for transparent colours). However, at least on my (Windows)
system, the text it outputs seems to have completely wrong kerning.
Here's an example:
CairoPDF("test.pdf")
plot(rnorm(100),xlab="Ovreset")
dev.off()
The v is (slightly) too far away from the O, it's much
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
2008 Apr 15
1
Text-based graphics/plots
When discussing statistics in e-mail based discussion groups, or in
newsgroups, it is sometimes useful to include simple, text-based
statistical graphics. Here is an example, a histogram (only useful
with a fixed-width font, obviously).
:.....
..:::::::::.
.:::::::::::::::
2011 Oct 11
1
controling text in facets (ggplot2)
Hi R-helpers!
Here is my problem:
I have a graph with 3 different facets where there are 3 different
regression line. My goal is to mention separately in each facet each
equation that describes my lines.
So far, I managed to add a line and the same equation to all my facets but
that's not unfortunately what I want.
Is there a way to do that? Any suggestion would be gladly welcome!
Thanks
2009 Dec 07
1
Subset of time observations where timediff > 60 secs
Dear list members
I have a rather large vector (part of a data frame) giving the time
(date + time, POSIXct) of observations. The times are irregular (with
both small and large jumps) but increasing, and there are several
millions of them.
I now wish to reduce my data set, so that I only have observations which
are at least (for example) 60 seconds apart. Basically, I need (all) the
indices
2009 Jun 22
1
The gradient of a multivariate normal density with respect to its parameters
Does anybody know of a function that implements the derivative (gradient) of
the multivariate normal density with respect to the *parameters*?
It?s easy enough to implement myself, but I?d like to avoid reinventing the
wheel (with some bugs) if possible. Here?s a simple example of the result
I?d like, using numerical differentiation:
library(mvtnorm)
library(numDeriv)
f=function(pars, xx, yy)
2008 Mar 04
1
qplot (ggplot2) faceting histogram with missing values
Hi,
I've run into a difficulty with qplot function (in the ggplot2
package). I can facet histograms even when the faceting variable
contains missing values, but only so long as the faceting variable is
not a factor.
Example:
y1 <- rnorm(10)
x1 <- c(rep(1,5), rep(2,4), NA)
x2 <- factor(c(rep(1,5), rep(2,4), NA))
library(ggplot2)
qplot(y1, geom = "histogram", facets =
2004 Mar 23
2
Tool for cutting Ogg Vorbis files
Anybody know of a tool for cutting/trimming Ogg Vorbis files?
I'm thinking of a tool similar to (the excellent) mp3DirectCut
"http://www.rz.uni-frankfurt.de/~pesch/#mp3dc" tool, only for
Vorbis.
I've tried musiCutter, but it's to difficult/time-consuming to
use.
BTW, the mp3DirectCut author says this in his FAQ:
Can you add Ogg Vorbis support?
I would,