ggplot2

Date labels overlap when putting multiple ggplot plots on single page

I am trying to put multiple ggplot2 time series plots on a page using the gridExtra package's arrange() function. Unfortunately, I am finding that the x-axis labels get pushed together; it appears that the plot is putting the same number of x-axis labels as a full-page chart, even though my charts only take up 1/4 of a page. Is there a b...

Time Stamps, Qplot and strptime in R.

This is a follow up question as hadley pointed out unless I fix the problem with the time stamps the graphs I produce would be incorrect. With this in mind I am working towards fixing the issues I am having with the code. So far I have from my earlier questions that have been answered stopped using the attach() function in favour of usin...

how to change the order of a discrete x scale in ggplot?

I am making a dodged bar chart using ggplot with discrete x scale, the x axis are now arranged in alphabetical order, but I need to rearrange it so that it is ordered by the value of the y-axis (i.e., the tallest bar will be positioned on the left), I tried order or sort, but result in sort the x-axis, but not the bars respectively. What...

can I change the position of the strip label in ggplot from the top to the bottom?

I know this is not quite a data visualization issue, but the boss asked for it, so I need to figure out if it is possible. Thanks! ...

how to change the width of the gaps between the panels in facet in ggplot2?

as title, I have having quite a lot of panels when generating a chart by ggplot, and I think the gap is a bit too wide, can I adjust it? Thanks! ...

ggplot2 binwidth with factor(variable)?

Dear all, I have simple histogram, but can't adjust the binwidth: qplot(factor(size_class),data=mydf,geom="histogram",binwidth = 0.01) size_class is a categorical variable (char) that groups mydf into groups according to another size variable. All I want to get is a graph like: plot(table(mydf$size_class) using ggplot2. The co...

facet label font size

Dear all, is there a way to change to font size of facet labels in ggplot? I google a bit and found that that issue was yet on Hadley's to do list. I wonder if there's a workaround or any news on this issue. Thx for sharing any news… ...

sweave and ggplot2: no pdfs generated at all

Dear all, i am trying create a sweave report that contains some graphics done with ggplot2. Though I am looking for some environment for the long run – I just use a simple .Rnw file here that only contains the code and the plot \documentclass[a4paper]{article} \SweaveOpts{echo=FALSE} \usepackage{a4wide} \begin{document} \begi...

using grid and ggplot2 to create join plots using R

I would like to know what can I do to fix a grid of plots. The plots are arranged in an array so that all the plots in a row have the same Y axis variable and all the plots in a column have the same X axis variable. When joined together in a grid this creates a multiplot. I disable the labels on most of the plots excepting the outer one...

invalid multibyte character crashes when script is loaded from source (umlauts / special characters)

EDIT: Thx to suggestions from the mailing list I realized that the problem I got has nothing to do with Sweave or Latex. It´s some Mac OS X related issue. Whenever I run my script by selecting all and sending it to R it works. When I use source("myplainRcode.R") i get the error message stated below finally I got sweave working ...

How do I get ggplot to order facets correctly?

I am trying to facet about 14 plots based on a variable that runs from 2-14. The plots show up in the order: 10,11,12,13,14,15,2,3,4,5,6,7,8,9 How do I get them to order from 2-15? update: ok, so I made it a factor using data$var=as.factor(data$var). The Levels are Levels: 10 11 12 13 14 15 2 3 4 5 6 7 8 9 How do I reorder those? ...

R + ggplot: plotting irregular time series

I have data at a number of days since an event. This data is sampled irregularly - my time points are like 0, 5, 6, 10, 104 days. I don't have specific date-time information - i.e. I have no idea when in real life the event I'm studying occurred. I'd like to plot, using ggplot, my time series. I can use, say p <- ggplot(data,aes(x=tim...

Can I use direct.label() with ggplot's scale_colour_manual()?

The following code assigns a manual color scale of red and black to my points: require(ggplot2) require(directlabels) dtest <- data.frame(x=1:20, y=rnorm(20,0,5), v=seq(1,2)) p <- ggplot(dtest, aes(x=x,y=y,color=as.factor(v))) + geom_point() + scale_colour_manual(values=c("red","black")) p #this looks...

Using seq.Date as breaks in stat_bin for time-series

I am attempting to bin time-series data from several years of observation by month using the stat_bin function in ggplot2. The code looks like this: month.breaks<-seq.Date(from=min(afg$DateOccurred),to=max(afg$DateOccurred),by="month") # All months, for breaks report.region<-ggplot(afg,aes(x=DateOccurred))+stat_bin(aes(y=..density..,f...

Possibly inconsistent behavior in qplot() ??

I'm trying to use qplot() to plot a simple time series as one might do using plot(). The x variable is as.POSIXlt and the y is just some continuous measurement. Here is the code with some brief comments. Any help on why these data.frames behave differently would be very much appreciated. As you can see below, I can work around the pr...

How to control the dimension / size of a plot with ggplot2

Dear all, I am using ggplot2 (respectively qplot) to generate a report with Sweave. Now I need some help with the adjustment of the size of the plot. I use the following Sweave code to include it. \begin{figure}[htbp] \begin{center} <<fig=true,echo=false>>= print(mygraph) @ \caption{MyCaption} \end{center} \end{figure} If I add a wi...

Overlay multiple stat_function calls in ggplot2

I have two data.frames, one containing raw data and the other containing modelling coefficients that I have derived from the raw data. More detail: The first data.frame "raw" contains "Time" (0s to 900s) and "OD" for many Variants and four runs. The second data.frame "coef" contains one row per Variant/run combination, with the individ...

How to adjust line size in geom_line without obtaining another (useless) legend?

Dear all, i´d like to adjust the size of my lines (both of them), because i feel they're too skinny. The following code does so, but creates a legend for size, which is useless since size has no variable that can be mapped to it. qplot(date,value,data=graph1,geom="line",colour=variable,xlab="",ylab="",size=1) + scale_y_continuous(lim...

R ggplot2: using stat_summary (mean) and logaritmic scale

I have a bunch of measurements over time and I want to plot them in R. Here is a sample of my data. I've got 6 measurements for each of 4 time points: values <- c (1012.0, 1644.9, 837.0, 1200.9, 1652.0, 981.5, 2236.9, 1697.5, 2087.7, 1500.8, 2789.3, 1502.9, 2051.3, 3070.7, 3105.4, 2692.5, 1488.5, 1978.1, 1925.4, 1524.3, ...

R + ggplot: plotting over multiple pages

I'm trying to write a function that plots a ggplot facet_wrap plot over multiple pages. It's just a hack, as this feature seems to be on the ggplot2 feature to-do list. I do some small calculations to find the number of pages I'm going to need, the number of rows of my data.frame that I need per page etc. I'm pretty confident this all wo...