I'm trying to generate a simple line graph of the iterations of a given natural number n, of the collatz conjecture, by importing the data from a csv file. For example, n=27 yields the attached data (I can't upload csv, so it's a txt file instead). I want to create a line graph like the one wikipedia displays, here:
http://upload.wikimedia.org/wikipedi...6/Collatz5.svg
where the data points aren't marked by some large point of an "o" or something to that effect. However, this code is all I can come up with:
which generates the attached jpeg, in which the data points are very obvious and the whole graph looks somewhat ugly. Can anyone help me create a better graph?Code:c <- read.csv("data_27.csv", head=TRUE, sep=",") max_x = max(c$n) max_y = max(c$Value) plot_colors <- c("blue","red","forestgreen") jpeg(filename="27.jpg", bg="white") plot(c$n, c$Value, pch=46, col=plot_colors[1], xlim=c(0, max_x), ylim=c(0, max_y), axes=FALSE, ann=FALSE) lines(c$Value, pch=46, lty=1, col=plot_colors[1]) axis(1, las=1, at=2*0:max_x) axis(2, las=1, at=2000*0:max_y) box() title(main="Collatz Sequence: 27", col.main="blue", font.main=3) title(xlab= "n", col.lab=rgb(0,0.5,0)) title(ylab= "Value", col.lab=rgb(0,0.5,0)) dev.off()
|
|