Exemplo n.º 1
0
# Mayor Library imports
from numpy import linspace, exp

# Enthought library imports
from enthought.chaco.shell import semilogy, hold, title, show


# Create some data
x = linspace(1, 10, 200)

# Create some line plots
semilogy(x, exp(x), "b-", name="y=exp(x)", bgcolor="white")
hold(True)
semilogy(x, x**x, "r--", name="y=x**x")
semilogy(x, x, "g-", name="y=x")

# Add some titles
title("simple semilog plots")

#This command is only necessary if running from command line
show()

Exemplo n.º 2
0
# Mayor Library imports
from numpy import linspace, random, pi

# Enthought library imports
from enthought.chaco.shell import plot, hold, title, show


# Create some data
x = linspace(-2*pi, 2*pi, 100)
y1 = random.random(100)
y2 = random.random(100)

# Create some scatter plots
plot(x, y1, "b.")
hold()
plot(x, y2, "g+", marker_size=2)

# Add some titles
title("simple scatter plots")

# This command is only necessary if running from command line
show()

Exemplo n.º 3
0
# Mayor Library imports
from numpy import linspace, meshgrid, sin
from scipy.special import jn

# Enthought library imports
from enthought.chaco.shell import show, title, contour


# Crate some scalar data
xs = linspace(-10, 10, 200)
ys = linspace(-10, 10, 400)
x, y = meshgrid(xs, ys)
z = sin(x) * x * jn(0, y)

# Create a contour line plot
contour(x, y, z, bgcolor="black")

# Add some titles
title("contour line plot")

# This command is only necessary if running from command line
show()
Exemplo n.º 4
0
# Mayor Library imports
from numpy import linspace, meshgrid, sin

# Enthought library imports
from enthought.chaco.shell import show, title, pcolor, colormap
from enthought.chaco.default_colormaps import jet


# Crate some scalar data
xs = linspace(0,10,200)
ys = linspace(0,20,400)
x,y = meshgrid(xs,ys)
z = sin(x) * y

# Create a pseudo-color-map
pcolor(x,y,z)

#change the color mapping
colormap(jet)

# Add some titles
title("pseudo colormap image plot")

#This command is only necessary if running from command line
show()
Exemplo n.º 5
0
# Mayor Library Imports
from numpy import linspace, meshgrid, tanh

# Enthought Library Imports
from enthought.chaco.shell import contourf, colormap, title, show
from enthought.chaco.default_colormaps import jet


# Crate some scalar data
xs = linspace(-10,10,200)
ys = linspace(-10,10,400)
x, y = meshgrid(xs,ys)
z = x * tanh(y)

# Create a filled contour plot
contourf(x,y,z)
colormap(jet)

# Add some titles
title("filled contour plot")

#This command is only necessary if running from command line
show()
Exemplo n.º 6
0
# Mayor Library imports
from numpy import linspace, pi, sin

# Enthought library imports
from enthought.chaco.shell import show, plot, title, curplot
from enthought.chaco.scales.api import CalendarScaleSystem

# Create some data
numpoints = 100
x = linspace(-2*pi, 2*pi, numpoints)
y1 = sin(x)

# Create the dates
import time
now = time.time()
dt = 24 * 3600    # data points are spaced by 1 day
dates = linspace(now, now + numpoints*dt, numpoints)

# Create some line plots
plot(dates, y1, "b-", bgcolor="white")

# Add some titles
title("Plotting Dates")

# Set the plot's horizontal axis to be a time scale
curplot().x_axis.tick_generator.scale = CalendarScaleSystem()

#This command is only necessary if running from command line
show()

Exemplo n.º 7
0
import sys

# Enthought library imports
from enthought.util.resource import find_resource
from enthought.chaco.shell import imread, imshow, title, show

# Get the image file using the find_resource module
image_path = os.path.join("examples", "basic", "capitol.jpg")
alt_path = os.path.join("..", "basic", "capitol.jpg")
image_file = find_resource("Chaco", image_path, alt_path=alt_path)

# Check to see if the image was found
if image_file is None:
    print 'The image "capitol.jpg" could not be found.'
    sys.exit()

# Create the image
image = imread(image_file)

# Create the plot
imshow(image, origin="top left")

# Alternatively, you can call imshow using the path to the image file
# imshow(alt_path)

# Add a title
title("Simple Image Plot")

# This command is only necessary if running from command line
show()
Exemplo n.º 8
0
# Mayor Library imports
from numpy import linspace, exp

# Enthought library imports
from enthought.chaco.shell import show, title, loglog, hold


# Create some data
x = linspace(1, 15, 200)

# Create some line plots
loglog(x, x ** 2, "b-.", name="y=x**2", bgcolor="white")
hold(True)
loglog(x, x ** 4 + 3 * x + 2, "r-", name="y=x**4+3x+2", bgcolor="white")
loglog(x, exp(x), "g-", name="y=exp(x)", bgcolor="white")
loglog(x, x, "m--", name="y=x", bgcolor="white")

# Add some titles
title("simple loglog plots")

# This command is only necessary if running from command line
show()
Exemplo n.º 9
0
# -*- coding: utf-8 -*-
import numpy as np
import enthought.chaco.shell as cs

x = np.linspace(-2 * np.pi, 2 * np.pi, 100)
y = np.sin(x)

cs.plot(x, y, "r-")
cs.title("First plot")
cs.ytitle("sin(x)")
cs.show()
Exemplo n.º 10
0
""" This example displays some line plots in different colors and styles using
the chaco.shell subpackage.  The functions in the chaco.shell package allow us
to quickly generate plots with some basic interactivity without using the
object-oriented core of Chaco.
"""

from numpy import linspace, pi, sin, cos
from enthought.chaco.shell import plot, hold, title, show

# Create some data
x = linspace(-2*pi, 2*pi, 100)
y1 = sin(x)
y2 = cos(x)

# Create some line plots using the plot() command and using
# Matlab-style format specifiers
plot(x, y1, "b-", bgcolor="white")
hold()
plot(x, y2, "g-.", marker_size=2)

# Set the plot title
title("simple line plots")

# If running this from the command line and outside of a wxPython
# application or process, the show() command is necessary to keep
# the plot from disappearing instantly.  If a wxPython mainloop
# is already running, then this command is not necessary.
show()

Exemplo n.º 11
0
# -*- coding: utf-8 -*-
import numpy as np
import enthought.chaco.shell as cs 

x = np.linspace(-2*np.pi, 2*np.pi, 100)
y = np.sin(x)

cs.plot(x, y, "r-") 
cs.title("First plot")
cs.ytitle("sin(x)")
cs.show()