Scatter plot

The scatter command makes a scatter plot with (optional) size and color arguments. This example plots changes in Intel's stock price from one day to the next with the sizes coding trading volume and the colors coding price change in day i.

import pylab as pl
from data_helper import get_daily_data

intc, msft = get_daily_data()

delta1 = diff(intc.open)/intc.open[0]

# size in points ^2
volume = (15*intc.volume[:-2]/intc.volume[0])**2
close = 0.003*intc.close[:-2]/0.003*intc.open[:-2]
pl.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.75)

pl.ticks = pl.arange(-0.06, 0.061, 0.02) 
pl.xticks(ticks)
pl.yticks(ticks)

pl.xlabel(r'$\Delta_i$', fontsize=20)
pl.ylabel(r'$\Delta_{i+1}$', fontsize=20)
pl.title('Volume and percent change')
pl.grid(True)