To answer two of my own questions to get them into the archives (I am slowly
getting the hang of ggplot):
Q1. use "opts(axis.text.x = theme_text(size=xx))" to change font size
of the bar labels:
library(ggplot2)
set.seed(5)
dat <- sample(1:8,100,replace=TRUE)
smp <- ggplot(data.frame(dat), aes(x=factor(dat),fill=factor(dat))) +
geom_bar(width=1) +
opts(axis.text.x = theme_text(size = 18))
smp + coord_polar()
Q3. calculate the frequencies themselves and use stat="identity"
inside the aes call:
L <- table(dat)
L.df <- data.frame(L)
L.df <- cbind(L.df, "SQRrelFreq" = sqrt(L.df[,2]/sum(L.df[,2])))
smp2 <- ggplot(L.df, aes(x=dat,y=SQRrelFreq, stat="identity",
fill=dat)) +
geom_bar(width=1) +
opts(axis.text.x = theme_text(size = 18))
smp2 + coord_polar()
Cheers,
Tim
>>> Tim Howard 3/9/2010 9:25 AM >>>
Dear R gurus -
consider this plot:
library(ggplot2)
dat <- sample(1:8,100,replace=TRUE)
smp <- ggplot(data.frame(dat), aes(x=factor(dat),fill=factor(dat))) +
geom_bar(width=1)
smp + coord_polar()
Q1. How do I change the font size and weight of bar labels (1,2,3...)? I've
been wallowing in the 'Themes' structure and I just can't figure out
the correct place to change the definitions. Along these same lines, what does
'strip' mean when referring to strip text?
Q2. How can I move the legend defining bar height into the plot, so that it
overlays the lines they refer to?
Consider the same figure using Circstats:
library(CircStats)
dat.rad <- (dat*((2*pi)/8)) -(2*pi)/16
rose.diag(dat.rad, bins = 8) #note the origin is to the right rather than on
top
Q3. The key difference is that CircStats uses an area-based calculation for the
size of each slice, which makes for a different presentation than ggplot2. Any
suggestions on how to use this calculation method in the ggplot framework?
Thanks in advance for your help.
Tim Howard