I am getting a small problem using ggplot2 geom_line graph.
When I apply ylim, the graph goes empty. In a default mode, the ggplot clutters up the y-axis with all the values, but I want to increase the reference limits to little big gaps, i.e from 17.3,17.5,17.7 to 17-18 with the graph intact. I am using ylim(c(15,30)), the limit is increased but graph disappears.
I tried using scale_y_continuous(breaks=c(15,30)):
[Error: Non-continuous variable supplied to scale_y_continuous]
and scale_y_discrete(breaks=c(15,30))
[Whole y bar disappears]

After limits:

DataFrame:
>head(meltedB)
Mouse Type days weight
1 21-H807 control 2011-09-23 27,0
2 21-H808 control 2011-09-23 27,8
3 21-H809/J125 knockout 2011-09-23 29,1
4 21-H810 control 2011-09-23 27,2
5 21-H811 control 2011-09-23 18,2
6 21-H812 control 2011-09-23 18,8
Command used :
ggplot(na.omit(meltedB),aes(factor(days),weight,group=Mouse)) +
geom_line(aes(color=Mouse),size=2) +
facet_grid(Type~.)
** For someone who is struggling with plotting of NA values, use na.omit on your dataframe, they wont be plotted.
There are two big hints that R has provided you to diagnose this problem. The first is the really ugly decision about the y axis tick labeling. The second is the explicit error message that says you passed a “non-continuous” variable to
scale_y_continuous.Your y variable is stored as a factor (or possibly a character). Type
str(meltedB)at the console to confirm.The problem is most likely the commas. You’ll need to go back to when you read in the data and change the
decargument toread.table, which is set to a period by default.