I am working with some time-frequency decomposed EEG data and want to produce a spectrogram-like figure using ggplot2. But, I end up with blank spaces between each of my time points.
Data <- read.csv(url("https://www.dropbox.com/s/al3cygigm86mr3s/Test_Spec_Data.csv?dl=0"))
If I create a vanilla geom_raster I get gaps in the x and y data:
ggplot(Data,aes(Times,Frequency)) +
geom_raster(aes(fill = ERSP))
If I make Frequency
a factor, it fills in the y gap; but, the gaps along the x-axis remain:
ggplot(Data,aes(Times,factor(round(Frequency,digits=1)))) +
geom_raster(aes(fill = ERSP))
I can eliminate the gaps by making Times
a factor.
But, managing scale_x_discrete
with this many data points is cumbersome (note the x-axis labels). Also, these time data are continuous and not really factor-like.
geom_raster
doesn't have a width
argument like geom_bar
and I can't see anything similar in the geom_raster
documentation.
Is there a way to keep Times
as continuous but remove the gaps between observations?