I have a nearly-boxplot like jitter-plot:
dt <- rbind(se,cb,cb.se)
qplot(ds, size, data=dt, geom="jitter", colour=root, facets = test ~ .)
I'd love to put a summary label for each group in the middle of the plot - for example the size totals here:
aggregate(list(size=dt$size), list(dt$ds, dt$test), sum)
Group.1 Group.2 size...
If I have data like this
DF <- data.frame(
date = seq(Sys.Date()-1000, len=1000, by="1 day")[sample(1000, 500)],
price = runif(500)
)
How do I plot e.g. mean of price in the function of time, e.g. in months, using ggplot2?
...
Is there some way to use a specific small image as a point in a scatterplot with ggplot2. Ideally I will want to resize the images based on an variable.
Here's an example:
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(aes(size = qsec, shape = factor(cyl)))
So I basically want to know if there is a way to supply a...
I'm looking to create a static dashboard viewable in a web browser. And I'd like to create something like what Stephen Few does in his book Information Dashboard Design. (see example at bottom)
Ggplot2: Shouldn't be any issue producing the graphs below, right?
Dashboard Layout: Is grid suitable? Or should I lay things out in html/css? ...
Is there a way of plotting a univariate time series of class "ts" using ggplot that sets up the time axis automatically? I want something similar to plot.ts() of base graphics.
Also it seems to me that the coarsest time granularity is a day. Is that right? In my work I have to work with monthly and quarterly data and assigning each obse...
Using ggplot, is there a way of graphing several functions on the same plot? I want to use parameters from a text file as arguments for my functions and overlay these on the same plot.
I understand this but I do not know how to add the visualized function together if I loop through.
...
I ran a Pig job on a Hadoop cluster that crunched a bunch of data down into something R can handle to do a cohort analysis. I have the following script, and as of the second to last line I have the data in the format:
> names(data)
[1] "VisitWeek" "ThingAge" "MyMetric"
VisitWeek is a Date. ThingAge and MyMetric are integers.
The...
I'm using qplot to plot a function and I want to position the legend within the plot. I've used
opts( legend.position = c(0.7,0.7) )
to move the legend where I want it to be.
However there is a white border around the legend and that shows up on the gray background.
For example:
library(ggplot2)
x = c(1:20)
y = c(1:20)
p <- qplo...
Using ggplot2 I am plotting several functions and a series of points. I cannot figure out how to represent the points on the legend. I realize I need to use an aes() function, but I don't fully understand how to do this. I apologize that the example is so long, but I don't know how else to illustrate it.
## add ggplot2
library(ggplot2)
...
After some research I found the way to prevent an uninformative legend from displaying
... + opts(legend.position = "none")
Where can I find all the available "opts" for ggplot2?
...
I'm using ggplot2 to explore the effects of different military operations on murder rates. To show the effect I draw a vertical line when the operation occurred and a smoothed line of the murder rate before and after the operation.
I've written a facet_wrap plot to show this for a whole bunch of counties. It works beautifully, but when...
I am trying to produce plots with a loop.
l1<-factor(rep(letters,4))
n1<-abs(rnorm(104))*10000
b1<-rep(c("1","2","3","4","5","6","7","8"),c(2,2,11,24,11,20,33,1))
k1<-rep((rep(c("A","B","C","D"),c(2,3,4,4))),8)
my.df<-data.frame(l1,b1,k1,n1) #make a dataframe
names(my.df)<-c("letter","branch","ltrtype","numbe...
In ggplot I can add a series to a plot with:
ggplot(diamonds, aes(x = carat, y = price)) + geom_point()
How do I simply add another series, e.g. plotting the cost of rubies against diamonds. Assuming rubies was also in the diamonds dataset. I have tried to lay over the top another layer with the rubies data, but it just plots the ru...
I've written an SQL query that tells me the names of the previous week's top 10 most frequent Alarms. And I've written a query that takes those top 10 alarms and provides a YTD weekly totals for each of those alarms.
Now I'm looking to create a panel of sparklines showing the YTD trend for each of the week's top 10 alarms.
I got somet...
Trying the ggplot2 examples in the online reference manual, and particularly in this page, I fail to produce all but the first of the second example's plots.
> d + stat_density2d(geom="tile", aes(fill = ..density..), contour = FALSE)
Error in `[<-.data.frame`(`*tmp*`, var, value = list(`NA` = NULL)) :
missing values are not allowed ...
In R it is easy to turn a matrix into a boxplot
> myMatrix
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 27 32 31 28 20 28 10 29 15 29
[2,] 31 33 20 28 21 9 14 21 34 33
[3,] 27 33 28 23 26 33 19 11 26 30
[4,] 33 17 10 31 10 32 10 29 31 ...
I have a plot (sample code pasted below) that I am trying to add by own labels for the series information. Instead of plotting "p1s1" "p1s2" "p3s4", I would like "treatment 1" "treatment 2" "treatment 3". I have used levels(series_id) to get the unique series names and used a lookup table to get the descriptions. (I think this gets th...
At the end of a ggplot, this works fine:
+ opts(title = expression("Chart chart_title..."))
But this does not:
chart_title = "foo"
+ opts(title = expression(chart_title))
nor this:
chart_title = "foo"
+ opts(title = chart_title)
How can I add a title to a ggplot when the title is a variable name?
...
I am trying to add a condition to geom_point size and I've pasted my example below. I would like geom_point size to be 2 when n_in_stat is 4 or more, and size = 5 when n_in_stat is less than 4. I tried putting an ifelse statement inside the geom_point, but this failed. Perhaps I can't include logical operators here and I have to crea...
I'm trying to generate a stacked area plot, but instead, ggplot makes overlapping areas. I've tried other examples that seems analogous to me, but they work and mine doesn't.
> cx
date type visitors
1 2009-11-23 A 2
2 2010-01-07 A 4
3 2010-01-09 A 6
4 2010-02-07 A 8
5 2009-12-02 B...