I'd like to create a geom_path() that has arrows pointing towards the next location in the path.
I can get the path to plot, without issue, for example:
df <- (x=1:12, y=20:31, z=1:12)
p <- ggplot(df, aes(x=x, y=y))
p + geom_point() + geom_path()
Now what I'd like to be able to do is plot that point arrows from one element in the p...
I'd like to know how to make it so that x and y, in the following example data set are plotted on the vertical axis for each element of frame in the horizontal axis. How do I do this with ggplot2?
x, y = variables, frame = YYYYMM
Example Data:
df <- structure(list(x = c(0.000892333625290767, 0.0161153931761482,
0.0188150880795816, 0...
Hello,
I've been learning ggplot in the last few weeks. Generally, I'm getting things done (slowly though), but now I'm stuck. I created the following facetted plot: http://dl.dropbox.com/u/7752237/example_bad_y_scales.pdf
Faceting is done by
pl <- pl + facet_wrap(~sci_name,ncol=1,scale="free")
The Problem: Numbers on the y-scale d...
I'm wondering if the following is possible.
I have a survey with 100+ questions, all categorical, collected in 4 locations. All questions are labeled q1, q2 and so on. Let's say there are 100 for simplicity.
I can visually compare the results of a particular question across locations with:
library (lattice);
histogram(~ q75 | location...
There is lots of cheat sheets for R. Is there a cheat sheet for ggplot2?
...
I have a bunch of histograms to plot on data that is still coming. As the sample sizes vary, in order to compare them I need to plot the histograms with percentages not counts.
qplot (field, data=mydata, geom="histogram", binwidth=10)
the above qplot displays the counts. The density option is not applicable as it divides the counts wi...
Say, I am using facet_grid() in ggplot2 to obtain 2 histograms. Now I want to superimpose these histograms with Poisson curves (having different means for the 2 histogram plots/grids) and a second curve of another distribution (for which I want to manually provide the probability function of values). How can this be done?
constructing ...
I would like to change the stacking order of hospitals in the diagram below so #1 is at the top and #4 at the bottom.
The diagram was produced with
ggplot(survey,aes(x=hospital, y=age))+geom_boxplot()+coord_flip()+xlab("")+ylab ("\nPatient Age")
and I need the top->down order to be the reverse of what is now. I'm not sure why it com...
I want to added dark/light phase information to the background of my stacked area graphset to highlight the how light affects the shapes of the curves. My dataframe looks like this:
> str(MDist.median)
'data.frame': 2880 obs. of 6 variables:
$ groupname: Factor w/ 8 levels "rowA","rowB",..: 1 1 1 1 1 1 1 1 1 1 ...
$ fCycle : Fact...
I have used the following ggplot command:
ggplot(survey,aes(x=age))+stat_bin(aes(n=nrow(h3),y=..count../n), binwidth=10)
+scale_y_continuous(formatter = "percent", breaks=c(0, 0.1, 0.2))
+ facet_grid(hospital ~ .)
+ opts(panel.background = theme_blank())
to produce
I'd like to change the facet labels, however, to something...
I wonder if it's possible to slice a graph respectively a .png file generated with ggsave. If I do not want to use the default legend ort title and set it to FALSE it leaves me with a lot of white space. So is there an R way to just cut the file several pixels above and below the graph itself?
Thx in advance!
...
I have time series data (I've posted it here as a data.frame):
x <- structure(list(date = structure(c(1264572000, 1266202800, 1277362800,
1277456400, 1277859600, 1278032400, 1260370800, 1260892800, 1262624400,
1262707200), class = c("POSIXt", "POSIXct"), tzone = ""), data = c(-0.00183760994446658,
0.00089738603087497, 0.0004235135983...
I generate a QQ plot to compare the distribution of my ranom number generator with a beta distribution. I can do this using the usual plot commands in R via
samples1 <- read.csv("test1-clean.dat")
qqplot( samples1$p0, qbeta(seq(0,1,length=length(samples1$p0)),1,3) )
abline( 0, 1 )
but I want to use the ggplot2 library, and I just can...
i am using rpy2-2.0.7 (i need this to work with windows 7, and compiling the binaries for the newer rpy2 versions is a mess) to push a two-column dataframe into r, create a few layers in ggplot2, and output the image into a <.png>.
i have wasted countless hours fidgeting around with the syntax; i did manage to output the files i neede...
The following code works well:
p <- ggplot(df,aes(x=x,y=y))
p <- p + geom_tile(aes(fill=z))
p
It plots a nice heatmap. Here df contains x and y, created using expand.grid(), and z which contains the value at each (x,y) co-ordinate.
This code, on the other hand
p <- ggplot(df,aes(x=x,y=y))
p <- p + coord_map(project="lagrange")
p <- ...
I've recently installed the latest version of ggplot, by downloading the source from CRAN and then running
install.packages("/path/to/ggplot2_0.8.8.tar.gz", repos = NULL, type="source")
Now, running the first example from geom_tile()'s documentation on the ggplot2 website:
library('ggplot2')
pp <- function (n,r=4) {
x <- seq(-r...
I have a list of matrices I wish to plot. Each element in the list ultimately represents a facet to be plotted. Each matrix element has dimensions Row * Col, where all values in a row are grouped and plotted as a scatterplot (i.e. X-axis is categorical for the row names, Y-axis is the value, Col. values per row).
Additionally, I would...
I am trying to produce some example graphics using ggplot2, and one of the examples I picked was the birthday problem, here using code 'borrowed' from a Revolution computing presentation at Oscon.
birthday<-function(n){
ntests<-1000
pop<-1:365
anydup<-function(i){
any(duplicated(sample(pop,n,replace=TRUE)))
}...
I'm looking for an easier way to draw the cumulative distribution line in ggplot.
I have some data whose histogram I can immediately display with
qplot (mydata, binwidth=1);
I found a way to do it at
http://www.r-tutor.com/elementary-statistics/quantitative-data/cumulative-frequency-graph
but it involves several steps and when explor...
Dear all,
I am trying to create facet grid with the following code
p <- ggplot(melted,aes(factor(country))) + geom_bar() +opts(axis.text.x = theme_text(angle = 90,hjust = 1))
p + facet_grid(. ~ provider)
but I always get the following error:
Error in sub("^[^:]+: ([^\n]+)\n[0-9]+:(.*)$", "\1\2", expr) :
input string 1 is in...