We may assume that we have CSV file and we want a very basic line plot with several lines on one plot and a simple legend.
The easiest way is to use R
read.csv to enter the data into R, then use a combination of the
ggplot2 the following commands should get you started.
require(ggplot2) #You would use read.csv here N = 10 d = data.frame(x=1:N,y1=runif(N),y2=rnorm(N), y3 = rnorm(N, 0.5)) p = ggplot(d) p = p+geom_line(aes(x, y1, colour="Type 1")) p = p+geom_line(aes(x, y2, colour="Type 2")) p = p+geom_line(aes(x, y3, colour="Type 3")) #Add points p = p+geom_point(aes(x, y3, colour="Type 3")) print(p)
This would give you the following plot:
Saving plots in R
Saving plots in R is straightforward:
#Look at ?jpeg to other different saving options jpeg("figure.jpg") print(p)#for ggplot2 graphics dev.off()
jpeg‘s you can also save as a
#This example uses R base graphics #Just change to print(p) for ggplot2 pdf("figure.pdf") plot(d$x,y1, type="l") lines(d$x, y2) dev.off()