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

« back to all changes in this revision

Viewing changes to examples/demo/shell/imshow.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
 
# Standard library imports
2
 
import os.path
3
 
import sys
4
 
 
5
 
# Enthought library imports
6
 
from traits.util.resource import find_resource
7
 
from chaco.shell import imread, imshow, title, show
8
 
 
9
 
# Get the image file using the find_resource module
10
 
image_path = os.path.join('examples','basic','capitol.jpg')
11
 
alt_path = os.path.join('..','basic','capitol.jpg')
12
 
image_file = find_resource('Chaco', image_path, alt_path=alt_path)
13
 
 
14
 
# Check to see if the image was found
15
 
if image_file is None:
16
 
    print 'The image "capitol.jpg" could not be found.'
17
 
    sys.exit()
18
 
 
19
 
# Create the image
20
 
image = imread(image_file)
21
 
 
22
 
# Create the plot
23
 
imshow(image, origin="top left")
24
 
 
25
 
# Alternatively, you can call imshow using the path to the image file
26
 
#imshow(alt_path)
27
 
 
28
 
# Add a title
29
 
title("Simple Image Plot")
30
 
 
31
 
# This command is only necessary if running from command line
32
 
show()