Dear all,
I'd like to produce a frequency power spectrum with EEG data. This works fine but coloring the area below the line by frequency bands does not work so well. Here is what I'd like to achieve:
Here's a data snipped with the data which underlies the above plot:
load(url("http://dl.dropbox.com/u/6281903/snippet.Rda"))
This is what the data looks like:
> head(dd)
Hz power band
1 0.9765625 0.123 delta
2 1.9531250 9.511 delta
3 2.9296875 0.777 delta
4 3.9062500 3.702 theta
5 4.8828125 5.138 theta
6 5.8593750 2.636 theta
The following code reduces the plot nicely but without coloring:
ggplot(data=dd, aes(x=Hz, y=power)) +
geom_area() +
theme_bw() + xlim(0, 32) + ylab(expression(paste(µV^2/Hz)))

Adding a fill aesthetic produces gaps between the frequency bands where the data was interpolated before:
ggplot(data=dd, aes(x=Hz, y=power)) +
geom_area(aes(fill=band)) +
scale_fill_brewer(palette = "Set1", na.value = NA, guide = "none") +
theme_bw() + xlim(0, 32) + ylab(expression(paste(µV^2/Hz)))

Is there some way how I can fix this plot? I'm grateful for any suggestions you might have.