Take the following two plots. The first one produces a broken line. In
the second one, the variable Phase is numeric and therefore it does not
break the line between two "Phases". I do not want the line to be
broken. That is why I am trying to do it by assigning a number to the
"Phase" and then use different labels in the legend. If I put the text
of those labels in the variable Phase itself, as done in the first
example, it gives me a broken line.
# Plot 1
data.frame(Year=c(1:20),CDR=rnorm(20))->b3
c(rep("a",10),rep("b",10))->b3$Phase
qplot(Year,CDR,data=b3,colour=Phase,geom=c("point","line"))
#Plot 2
data.frame(Year=c(1:20),CDR=rnorm(20))->b3
c(rep(1,10),rep(2,10))->b3$Phase
qplot(Year,CDR,data=b3,colour=Phase,geom=c("point","line"))->p
p+scale_colour_gradient2(limits=c(1,2),
midpoint=1.5,low="magenta",high="darkblue",breaks=c(1,2),labels=c("a","b"))
In the past, I have used "(print(p,pretty=F)->p)" to do away with the
legend. But it gives an error in the latest version of ggplot2. The
error I get is:
Error in ggplotGrob(x, ...) : unused argument(s) (pretty = FALSE)
Is it a bug or something has been changed. I shall appreciate any help.
Vikas
Thanks. This is perfect.
ggplot has come a long way over the last couple of years that I have
been using it. Congratulations and thanks for all the work that you have
put in.
Having said that, it is sometimes frustrating to find that a code which
used to work earlier has stopped working. Frustration is perhaps not the
right word because one can always ask on the mailing lists, and you are
always there to help. But then, I do hope that the syntax will become
more stable in future.
But on the whole, great show!!
Thanks,
Vikas
I know it's frustrating - the syntax is slowly stabilising, but there
will probably be a few more changes before it all settles down. I'm
still trying to optimise the syntax, rather than maintain backward
compatibility. That will change as I get closer and closer to ggplot2
1.0.
Hadley