Reputation: 607
I have composed a plot in r using ggplot2. Codes are as follows. My data set is net_d. Ratio varies between 0.5 - 1.0. D2 goes from 10 - 1.
p<-ggplot(net_d,aes(Ratio,D2))
p<-p+geom_point()+geom_line()
p<-p+xlab("Multiples of degrees of nodes within community to between community")
p<-p+ylab("Faction of vertices classfied correctly")
#p<-p+scale_x_continuous(breaks=c(seq(10,1,by=-1)))
p<-p+xlim(10,1)+ylim(0.5,1)
p<-p+theme_set(theme_grey())
print(p)
I need to have labels in x-axis 10 - 1, by steps of 1. Therefore each point in plot will have a corresponding tick mark at x-axis. I have comment a possible solution. But that reverse the labels to 1-10. I need it other way around.
Upvotes: 2
Views: 1487
Reputation: 23818
This should work:
library(ggplot2)
coords <- rev(seq(1:10))
vals <- c(rep(1,6),0.98,0.73,0.64,0.66) #approximately extracted from your graph
df <- as.data.frame(rbind(coords,vals))
p <- ggplot(df,aes(x=coords,y=vals))
p <- p + geom_point() + geom_line()
p <- p + xlab("Multiples of degrees of nodes within community to between community")
p <- p + ylab("Faction of vertices classfied correctly")
p <- p + theme_bw()
p <- p + ylim(0.5,1)
p <- p + scale_x_reverse(breaks=c(seq(1,10)))
Here's the output:
Hope this helps
Upvotes: 2
Reputation: 3872
You can use scale_x_reverse
:
#using the cars database
p<-ggplot(cars,aes(speed,dist))
p<-p+geom_point()+geom_line()
p<-p+xlab("Multiples of degrees of nodes within community to between community")
p<-p+ylab("Faction of vertices classfied correctly")
p<-p+scale_x_reverse(breaks=c(seq(1,25,by=1)))
p<-p+ylim(1,100)
p<-p+theme_set(theme_grey())
print(p)
Upvotes: 0