#!/bin/env python

import pylab as p
from matplotlib.lines import Line2D

def run( usedate ):
   t0 = 730485.0
   lines1 = [
      Line2D( [t0,t0+1], [2,3], linestyle = "", marker = 'x' ),
      Line2D( [t0+2,t0+3], [-2,-3], linestyle = "", marker = 'x' ),
      ]

   lines2 = [
      Line2D( [t0+4,t0+5], [4,5], linestyle = "", marker = 'x' ),
      Line2D( [t0+6,t0+7], [-4,-5], linestyle = "", marker = 'x' ),
      ]


   fig = p.figure()
   ax = p.gca()
   if usedate:
      ax.xaxis_date()

   for l in lines1:
      ax.add_line( l )

   ax.autoscale_view()
   fig.show()

   raw_input("press return...")

   fig.clear()
   ax = fig.gca()
   if usedate:
      ax.xaxis_date()

   for l in lines2:
      ax.add_line( l )

   ax.autoscale_view()
   ax.figure.canvas.draw()

   raw_input("press return...")

   fig.clear()
   ax = fig.gca()
   if usedate:
      ax.xaxis_date()

   for l in lines1:
      ax.add_line( l )

   ax.autoscale_view()
   ax.figure.canvas.draw()

   raw_input("press return...")
   
# Run w/o dates - works fine
run( False )

# run w/ dates - errors
run( True )
