~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to examples/demo/shell/dates.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""This example demonstrates using dates as labels for the axis ticks using
2
 
the chaco shell subpackage.
3
 
 
4
 
Try zooming in and out using the mouse wheel and see the resolution of
5
 
the dates gradually changing from days to years.
6
 
"""
7
 
 
8
 
# Major library imports
9
 
from numpy import linspace, pi, sin
10
 
 
11
 
# Enthought library imports
12
 
from chaco.shell import show, plot, title, curplot
13
 
from chaco.scales.api import CalendarScaleSystem
14
 
 
15
 
# Create some data
16
 
numpoints = 100
17
 
x = linspace(-2*pi, 2*pi, numpoints)
18
 
y1 = sin(x)
19
 
 
20
 
# Create the dates
21
 
import time
22
 
now = time.time()
23
 
dt = 24 * 3600    # data points are spaced by 1 day
24
 
dates = linspace(now, now + numpoints*dt, numpoints)
25
 
 
26
 
# Create some line plots
27
 
plot(dates, y1, "b-", bgcolor="white")
28
 
 
29
 
# Add some titles
30
 
title("Plotting Dates")
31
 
 
32
 
# Set the plot's horizontal axis to be a time scale
33
 
curplot().x_axis.tick_generator.scale = CalendarScaleSystem()
34
 
 
35
 
#This command is only necessary if running from command line
36
 
show()
37