Wednesday, May 8, 2013

PL#2: XY scatter plot with multiple data series


#!/usr/bin/env python

from __future__ import print_function

from pylab import *

x = array([10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5])
y1 = array(3 + x*0.5 + np.random.rand(len(x) ))
y2 = array(3 - x*0.6 + np.random.rand(len(x) ))

def fit1(x):
      return 3+0.5*x
xfit = array( [amin(x), amax(x) ] )

plot(x,y1,'ks', xfit, fit1(xfit), 'r-', lw=2, marker='o',
markerfacecolor='blue', markersize=10)


xlabel('x-axis')
ylabel('y-axis')
title(r'regression plots')






# add second data series 
def fit2(x):
     return 5 - 0.6*x

plot(x,y2,'ks', xfit, fit2(xfit), 'r-', lw=2, marker='v',
markerfacecolor='green', markersize=10)
setp(gca(), yticks=(-8,-6,-4, -2, 0,2, 4, 6, 8, 10), xticks=(2,4,6, 8,10, 12, 14, 16))
text(14.5,11, 'eq-I', fontsize=10, color = "blue" )
text(14.5,-2, 'eq-II', fontsize=10, color = "green" )




No comments:

Post a Comment