My data disappears when I truncate the y-axis to show only the 50 to 90 range. Am I putting the ylim in the wrong place?
The spreadsheet looks like this:
xval yval_LWTW linenames SNP
1 61.4835166 MT9513 NN
2 61.93341478 RITA GG
3 63.31277751 JUDITH CC
4 63.60466558 CO04W320 GG
5 64.84700514 DECADE NN
library(ggplot2)
library(xlsx)
data <- read.xlsx("RdataForGraphsofBestHits.xlsx", sheetIndex=4)
ggplot(data, aes(x=xval, y=yval_LWTW, fill=SNP,
scale_fill_manual(values=c(GG="blue",CC="red",NN="green")))) +
geom_bar(stat="identity", width=1) +
theme(axis.title.x=element_blank())
This gives me a tall plot because the data go from 61 to 81. I want to make the y-axis start at 50, so the plot will be shorter, so I add + ylim(50.0, 90.0) to the code.
library(ggplot2)
library(xlsx)
data <- read.xlsx("RdataForGraphsofBestHits.xlsx", sheetIndex=4)
ggplot(data, aes(x=xval, y=yval_LWTW, fill=SNP,
scale_fill_manual(values=c(GG="blue", CC="red", NN="green")))) +
geom_bar(stat="identity", width=1) +
theme(axis.title.x=element_blank()) +
ylim(50.0, 90.0)
Now I get the gray background of the plot with the y-axis nicely limited to the 50 to 90 range, but no data plotted onto it. Just the gray background and the axis labels and the legend.
I think I have the code for making the plot horizontal.
ggplot(data, aes(x=xval, y=yval_LWTW, fill=SNP,
scale_fill_manual(values=c(GG="blue", CC="red", NN="green")))) +
geom_bar(stat="identity", width=1) +
theme(axis.title.x=element_blank()) +
coord_fixed(ratio=1/2)
So I can fix the horizontal problem if I can fix the disappearing data problem.