I have a table available here: http://ulozto.cz/xAeP3Ahn/res2-txt . I'm trying to make a point plot out of this.
I read my table:
res2<-read.table("res2.txt", header = TRUE, sep="\t")
and create 2 graphics.
(1) This is a script function for single printing:
plot(res2$V2, res2$dist06, type = "n") points(subset(res2$V2, year == 2006), subset(res2$dist06, year == 2006), pch = 19, col = "red", cex = 1) points(subset(res2$V2, year == 2007), subset(res2$dist06, year == 2007), pch = 19, col = "green", cex = 1) points(subset(res2$V2, year == 2008), subset(res2$dist06, year == 2008), pch = 19, col = "black", cex = 1) points(subset(res2$V2, year == 2009), subset(res2$dist06, year == 2009), pch = 19, col = "blue", cex = 1) points(subset(res2$V2, year == 2011), subset(res2$dist06, year == 2011), pch = 19, col = "yellow", cex = 1) legend("topright", c("2006", "2007", "2008", "2009", "2011"), col= c("red", "green", "black", "blue", "yellow"), pch = c(19,19,19,19,19))
(2) and for ggplot2:
res2$year<-as.factor(res2$year) # consider year variable as discrete ggplot(data=res2, aes(x=V2, y=dist06, color=year)) + geom_point(shape=16, pch=50) + xlab("threshold") + ylab("Euclidean distance") + scale_fill_hue(name="year") + # set legend title scale_colour_manual(values=c("red", "green", "black", "blue", "yellow")) + theme_bw()
Here are my results:

My question is: why do I have a different position of the points on the charts generated differently? - the problem is only in different colors and legends? are the so-called "subsets" defined incorrectly? Why is 2006 marked as red in both, but has a different position in the chart? same with 2011 and others? Where am I mistaken? Thanks for all the recommendations, I lost the third day here.
Here are my results from excel, so the plot from ggplot2 (2) should be right 