Is there a simple way to make a nice plot of the following data in R, without using many commands?
Region1 Region2
2007 17 55
2008 26 43
2009 53 70
2010 96 58
I do know how to plot the data, but it uses too many commands and parameters, and the result still looks absolutely terrible (see here):
> test <- read.table("/tmp/data.txt")
> png(filename="/tmp/test.png", height=1000, width=750, bg="white", res=300)
> plot(test$Region1, type="b", col="blue", ylim=c(0,100), lwd=3)
> lines(test$Region2, type="b", col="red", lwd=3)
> dev.off()
It took me a while to figure out all the commands, and I still have to get the x axis labels (2007, 2008, ...), using the axis
command (but how do I access the test
x axis labels?), etc.
In Keynote (or Powerpoint) I can just give it the same table (transposed) and it produces a nice graph from it (see here).
My question is really: Is there a higher-level command that draws such typical data nicely? Also, how can I separate the drawing logic (draw 2 lines from that specific data, etc.) from the layout (use specific colors and line types for the graph, etc.)? Ideally, I'd hope there were different libraries for different layouts of the graph, e.g. called NiceKeynoteLayout
, which I just could use like this (or similar):
> d <- read.table("/tmp/data.txt")
> png <- png(filename="/tmp/test.png", height=1000, width=750)
> myLayout <- loadPredefinedLayout("NiceKeynoteLayout")
> coolplot(d, layout=myLayout, out=png)