Commit 61a8a483 authored by panos's avatar panos Committed by Jérome Perrin

Insert Plot to graph two data sets

parent 100628dd
...@@ -65,7 +65,7 @@ class Graphs: ...@@ -65,7 +65,7 @@ class Graphs:
rdev rdev
return output return output
def Barplot(data,fileName="barplot.jpg"): def Barplot(self,data,fileName="barplot.jpg"):
data=robjects.FloatVector(data) #The given list changes into float vector in order to be handled by RPy2 data=robjects.FloatVector(data) #The given list changes into float vector in order to be handled by RPy2
rbarplot=robjects.r['barplot'] #Call barplot - R function rbarplot=robjects.r['barplot'] #Call barplot - R function
...@@ -77,6 +77,35 @@ class Graphs: ...@@ -77,6 +77,35 @@ class Graphs:
rdev rdev
return output return output
def TwoSetPlot(self, data1,data2, fileName="twosetplot.jpg"):
#The given lists change into float vector in order to be handled by RPy2
data1=robjects.FloatVector(data1)
data2=robjects.FloatVector(data2)
rplot=robjects.r['plot'] #Call plot - R function
rdev=robjects.r['dev.off']
rjpeg=robjects.r['jpeg']
rlines=robjects.r['lines'] #Call lines function - R function
rbox=robjects.r['box'] #Call box function - R function
rrange=robjects.r['range'] #Call range - R function
plot_colors= robjects.StrVector(["red", "forestgreen"]) #Define colors to be used in the plot
output=rjpeg(fileName)
rplot(data1, xlab="x", ylab="Total",ylim=rrange(data1,data2)) #Graph the first data sample and set axes' names
rlines(data2) #Graph the second data sample
# Create box around plot
rbox()
# Graph data1 with thicker red dashed line
rlines(data1, type="l", lty=2, lwd=2, col=plot_colors[0])
# Graph data2 with thicker green dotted line
rlines(data2, type="l", lty=3, lwd=2, col=plot_colors[1])
rdev
return output
def Pie(self, data1, fileName="pieChart.jpg"): def Pie(self, data1, fileName="pieChart.jpg"):
data1=robjects.FloatVector(data1) #The given list changes into float vector in order to be handled by RPy2 data1=robjects.FloatVector(data1) #The given list changes into float vector in order to be handled by RPy2
rpaste=robjects.r['paste'] #Call paste - R function rpaste=robjects.r['paste'] #Call paste - R function
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment