I have a data set that I cut into 7 equal bins using the cut()
function. I then converted the data back to a data frame using data.frame()
, then plotted this using ggplot, as seen below:
library(ggplot2)
set.seed(1)
data <- runif(n=53,200,1400)
# converted the data to a value and broke it down from lowest data point to highest data point:
a-tub.val <- cut(as.numeric(as.character(data)), breaks = seq(0, 1400, by = 200))
#converted this to a data frame to read into ggplot
a_tub.dat <- data.frame(a_tub.val)
# then ran my ggplot code:
ggplot(data = a_tub.dat) +
geom_bar(mapping = aes(x=a_tub.val, fill = a_tub.val)) +
theme(text = element_text(size=20), axis.text.x = element_text(angle=90, hjust=1), legend.title = element_text(size = 12)) +
ggtitle("Alpha-Tubulin Signals") +
labs(y="Number in Category", x="Fluoresence bins", fill ="Fluorescence (in thousands)")
packages used were XLConnect
and ggplot2
This displays only 4 bars on the ggplot (those that had values), instead of the 7 that I would like to achieve. Would anyone know a way to display those empty bins that contain no data, but should still be viewed on the graph?