R is a strong language. And there is a way in python with that R can be used that is called Rpy http://rpy.sourceforge.net/
its easy to install. here I will show you an example to create simple graphics using rpy
from rpy import *
def create_simple_bar_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;
r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
r.plot(r.table(r.rpois(150,7)),ylab=”hospital”,xlab=”patient”, type = “h”, col = “red”, lwd=10,main=”number of patients per hospital”)
r.dev_off()
def create_hist_with_R(file_name,size=5,bottom=1,left=1,top=0,right=0):
x = [24,60,18,63,32,47,88,64,72,87,100,16,37,46,50,\
64,11,45,77,35,38,39,84,90,6,87,25,67,51,71,52,\
98,57,5,65,75,8,68,35,75,95,29,50,44,30,1,92,93,\
56,56]
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;
r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
#r.plot(r.table(r.rpois(100,5)),xlab=”frequency”, type = “h”, col = “red”, lwd=10,main=”rpois(100,lambda=5)”)
r.hist(x, xlab=”frequency”, ylab=”count”, main=”histogram example using R”, col=’cyan’)
r.dev_off()
def create_simple_bar_chart_rainbow(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;
r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
r.plot(r.cos, -r.pi, 2*r.pi,col=r.rainbow(20),ylab=”biologic”,xlab=”total”,main=”Test Data”)
r.dev_off()
def draw_pie_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;
r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
r.pie(r.rep(1, 24), col = r.rainbow(24), radius = 0.9,main=”test pie chart”)
r.dev_off()
draw_pie_chart(“rgraphics_pie.pdf”,5,1,1,0,0)
create_hist_with_R(“rgraphics_hist.pdf”,5,1,1,0,0)
create_simple_bar_chart(“rgraphics_bar.pdf”,4,5.5,0.5,0,0)