> library(ggplot2) > df<- read.csv("c:\\tmp\\testsolution.csv") > # > # Utopia Point > # > U<-data.frame("Cost"=min(df$Cost), + "Weight"=min(df$Weight), + "Performance"=max(df$Performance)) > # > # Ranges > # > R<-data.frame("Cost"=max(df$Cost)-min(df$Cost), + "Weight"=max(df$Weight)-min(df$Weight), + "Performance"=max(df$Performance)-min(df$Performance)) > # > # add column wit distance to Utopia point to df > # > df$Distance = sqrt( + ((df$Cost-U$Cost)/R$Cost)^2+ + ((df$Weight-U$Weight)/R$Weight)^2+ + ((df$Performance-U$Performance)/R$Performance)^2 + ) > # > # Compromise point > # > mindist = min(df$Distance) > C=df[df$Distance==mindist,c("Cost","Weight","Performance")] > C=rbind(C,U) > > ggplot(data=df,aes(x=Cost,y=Performance))+ + geom_point(aes(color=Weight))+ + scale_color_gradientn(colors = rev(rainbow(5)))+ + ggtitle("testsolution.csv")+ + theme(legend.key.height=unit(4, "line"))+ + geom_point(x=U$Cost,y=U$Performance,size=3,color='black')+ + geom_path(data=C,x=C$Cost,y=C$Performance) > ggplot(data=df,aes(x=Weight,y=Performance))+ + geom_point(aes(color=Cost))+ + scale_color_gradientn(colors = rev(rainbow(5)))+ + ggtitle("testsolution.csv")+ + theme(legend.key.height=unit(4, "line"))+ + geom_point(x=U$Weight,y=U$Performance,size=3,color='black')+ + geom_path(data=C,x=C$Weight,y=C$Performance)
|